Potential fix for option saving

This commit is contained in:
2022-01-25 23:34:37 +03:00
parent 41b49370f9
commit 8ca58f7596
7 changed files with 23 additions and 10 deletions
+14
View File
@@ -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();
}
}
}
+1 -2
View File
@@ -71,8 +71,7 @@ namespace Kruzya.TelegramBot.Core
await databaseContext.Users.AddAsync(new BotUser()
{
ChatId = chat,
UserId = user,
BotUserId = new Guid()
UserId = user
});
}
}