Code cleanup

This commit is contained in:
2022-01-22 17:13:38 +03:00
parent 401f9fb529
commit ff63d6dfaa
13 changed files with 232 additions and 138 deletions
+2 -2
View File
@@ -114,7 +114,7 @@ namespace West.TelegramBot.ChatManagement.Handler
}
receiverRepOption.SetValue(receiverRepCount);
Db.MarkAsModified(receiverRepOption);
Db.Update(receiverRepOption);
await Reply($"{From.ToHtml()}<code>({await GetUserReputation(From)}) " +
$"{action} репутацию </code>{receiver.ToHtml()}<code>({Math.Round(receiverRepCount, 2)})</code>");
@@ -138,7 +138,7 @@ namespace West.TelegramBot.ChatManagement.Handler
reputation = Math.Round(reputation, 2);
var opt = await GetReputationOption(RepliedUser);
opt.SetValue(reputation);
Db.MarkAsModified(opt);
Db.Update(opt);
await Reply(
new HtmlString()
+2 -2
View File
@@ -19,7 +19,7 @@ namespace West.TelegramBot.ChatManagement.Handler
var opt = await Db.UserValues.FindOrCreateOption(Chat.Id, "rulesMsgId");
opt.SetValue(replyToMessage.MessageId);
Db.MarkAsModified(opt);
Db.Update(opt);
}
[Command(InChat.Public, "rules", CommandParseMode.Both)]
@@ -37,7 +37,7 @@ namespace West.TelegramBot.ChatManagement.Handler
}
catch (ApiRequestException)
{
Db.MarkAsDeleted(opt);
Db.UserValues.Remove(opt);
throw;
}
}
+2 -2
View File
@@ -24,7 +24,7 @@ namespace West.TelegramBot.ChatManagement.Handler
var warnOption = await GetWarnOption(warnUser);
var warnCount = warnOption!.GetValue<int>() + 1;
warnOption.SetValue(warnCount);
Db.MarkAsModified(warnOption);
Db.Update(warnOption);
await Bot.SendTextMessageAsync(Chat.Id, $"{warnUser.ToHtml()}<code>, Вам выдано предупреждение! " +
$"Текущее кол-во: {warnCount}/3</code>",
@@ -49,7 +49,7 @@ namespace West.TelegramBot.ChatManagement.Handler
warnCount = Math.Max(warnCount - 1, 0);
warnOption.SetValue(warnCount);
Db.MarkAsModified(warnOption);
Db.Update(warnOption);
await Bot.SendTextMessageAsync(Chat.Id,
$"{RepliedUser.ToHtml()}<code>, с Вас снято предупреждение! " +
@@ -47,7 +47,7 @@ namespace West.Entertainment.Handler.Fun
var animationFileOption = await GetAnimationFileOption();
animationFileOption.SetValue(animation.FileId);
_db.MarkAsModified(animationFileOption);
_db.Update(animationFileOption);
}
// ReSharper disable once MemberCanBeProtected.Global
@@ -77,7 +77,7 @@ namespace West.Entertainment.Handler.Fun
replyToMessageId: GetMessageIdToReply() ?? Message?.MessageId);
nextUseOption.SetValue(DateTime.Now + Cooldown);
_db.MarkAsModified(nextUseOption);
_db.Update(nextUseOption);
return true;
}
+2 -2
View File
@@ -290,7 +290,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
.Where(subscriber => subscriber.Feed == feed && subscriber.SubscriberId == chat.Id)
.Select(subscriber => subscriber.SubscriptionId).FirstAsync();
_dbContext.MarkAsDeleted(_dbContext.Find<Subscriber>(subId));
_dbContext.Subscriptions.Remove(_dbContext.Find<Subscriber>(subId));
}
else
{
@@ -298,7 +298,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
subscription.Feed = feed;
subscription.SubscriberId = chat.Id;
_dbContext.MarkAsCreated(subscription);
_dbContext.Subscriptions.Add(subscription);
}
await _dbContext.SaveChangesAsync();
+1 -1
View File
@@ -109,7 +109,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
await ProcessFeed(feed, dbContext);
feed.UpdatedAt = DateTime.Now;
dbContext.MarkAsModified(feed);
dbContext.Update(feed);
}
await dbContext.SaveChangesAsync();
+1 -1
View File
@@ -56,7 +56,7 @@ namespace UserGroupTag
tagDictionary[groupName] = memberList;
userGroupOption.SetValue(tagDictionary);
_db.MarkAsModified(userGroupOption);
_db.Update(userGroupOption);
_userCache.SetValue(repliedMessage.From.Id, repliedMessage.From, Int32.MaxValue);
await Bot.SendTextMessageAsync(chatId, $"{from.ToHtml()} добавлен в группу {groupName}",