mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Fix user option values on .NET 5+
This commit is contained in:
@@ -30,8 +30,14 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="dbContext"></param>
|
||||
/// <param name="entity">Entity for marking as modified.</param>
|
||||
public static void MarkAsModified(this DbContext dbContext, object entity) =>
|
||||
dbContext.Entry(entity).State = EntityState.Modified;
|
||||
public static void MarkAsModified(this DbContext dbContext, object entity)
|
||||
{
|
||||
var entry = dbContext.Entry(entity);
|
||||
if (entry.State == EntityState.Added)
|
||||
return;
|
||||
|
||||
entry.State = EntityState.Modified;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -97,6 +103,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
if (opt == null)
|
||||
{
|
||||
opt = repository.Create();
|
||||
opt.Name = option;
|
||||
opt.BotUser = await repository.GetService<CoreContext>().Users.FindOrCreate(chatId, userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user