UnitOfWork compltely removed. GetDbContext now returns a NadekoContext. Changed every access to contect via uow._context to uow

This commit is contained in:
Kwoth
2021-06-19 05:16:27 +02:00
parent 51a4499809
commit c127dcd1e3
81 changed files with 404 additions and 512 deletions

View File

@@ -33,19 +33,19 @@ namespace NadekoBot.Core.Services
};
private bool InternalChange(ulong userId, string userName, string discrim, string avatar,
string reason, long amount, bool gamble, IUnitOfWork uow)
string reason, long amount, bool gamble, NadekoContext uow)
{
var result = uow._context.TryUpdateCurrencyState(userId, userName, discrim, avatar, amount);
var result = uow.TryUpdateCurrencyState(userId, userName, discrim, avatar, amount);
if (result)
{
var t = GetCurrencyTransaction(userId, reason, amount);
uow._context.CurrencyTransactions.Add(t);
uow.CurrencyTransactions.Add(t);
if (gamble)
{
var t2 = GetCurrencyTransaction(_bot.Id, reason, -amount);
uow._context.CurrencyTransactions.Add(t2);
uow._context.TryUpdateCurrencyState(_bot.Id, _bot.Username, _bot.Discriminator, _bot.AvatarId, -amount, true);
uow.CurrencyTransactions.Add(t2);
uow.TryUpdateCurrencyState(_bot.Id, _bot.Username, _bot.Discriminator, _bot.AvatarId, -amount, true);
}
}
return result;

View File

@@ -56,7 +56,7 @@ namespace NadekoBot.Core.Services.Impl
using (var uow = _db.GetDbContext())
{
var gc = uow._context.GuildConfigsForId(guildId, set => set);
var gc = uow.GuildConfigsForId(guildId, set => set);
gc.Locale = ci.Name;
uow.SaveChanges();
}
@@ -74,7 +74,7 @@ namespace NadekoBot.Core.Services.Impl
{
using (var uow = _db.GetDbContext())
{
var gc = uow._context.GuildConfigsForId(guildId, set => set);
var gc = uow.GuildConfigsForId(guildId, set => set);
gc.Locale = null;
uow.SaveChanges();
}