mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Potential fix for option saving
This commit is contained in:
@@ -37,4 +37,18 @@ public static class DbContextExtension
|
||||
|
||||
entry.State = EntityState.Modified;
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(this DbContext dbContext, object entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
dbContext.Update(entity);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException e)
|
||||
{
|
||||
dbContext.Add(entity);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
await databaseContext.Users.AddAsync(new BotUser()
|
||||
{
|
||||
ChatId = chat,
|
||||
UserId = user,
|
||||
BotUserId = new Guid()
|
||||
UserId = user
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user