mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
UnitOfWork compltely removed. GetDbContext now returns a NadekoContext. Changed every access to contect via uow._context to uow
This commit is contained in:
@@ -46,7 +46,7 @@ DELETE FROM Clubs;";
|
||||
int res;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
res = await uow._context.Database.ExecuteSqlRawAsync(sql);
|
||||
res = await uow.Database.ExecuteSqlRawAsync(sql);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ DELETE FROM Clubs;";
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conn = uow._context.Database.GetDbConnection();
|
||||
var conn = uow.Database.GetDbConnection();
|
||||
using (var cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
@@ -97,31 +97,31 @@ DELETE FROM Clubs;";
|
||||
using var uow = _db.GetDbContext();
|
||||
|
||||
// get waifu info
|
||||
var wi = await uow._context.Set<WaifuInfo>()
|
||||
var wi = await uow.Set<WaifuInfo>()
|
||||
.FirstOrDefaultAsyncEF(x => x.Waifu.UserId == userId);
|
||||
|
||||
// if it exists, delete waifu related things
|
||||
if (!(wi is null))
|
||||
{
|
||||
// remove updates which have new or old as this waifu
|
||||
await uow._context
|
||||
await uow
|
||||
.WaifuUpdates
|
||||
.DeleteAsync(wu => wu.New.UserId == userId || wu.Old.UserId == userId);
|
||||
|
||||
// delete all items this waifu owns
|
||||
await uow._context
|
||||
await uow
|
||||
.Set<WaifuItem>()
|
||||
.DeleteAsync(x => x.WaifuInfoId == wi.Id);
|
||||
|
||||
// all waifus this waifu claims are released
|
||||
await uow._context
|
||||
await uow
|
||||
.Set<WaifuInfo>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.Claimer.UserId == userId)
|
||||
.UpdateAsync(x => new WaifuInfo() {ClaimerId = null});
|
||||
|
||||
// all affinities set to this waifu are reset
|
||||
await uow._context
|
||||
await uow
|
||||
.Set<WaifuInfo>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.Affinity.UserId == userId)
|
||||
@@ -129,16 +129,16 @@ DELETE FROM Clubs;";
|
||||
}
|
||||
|
||||
// delete guild xp
|
||||
await uow._context
|
||||
await uow
|
||||
.UserXpStats
|
||||
.DeleteAsync(x => x.UserId == userId);
|
||||
|
||||
// delete currency transactions
|
||||
await uow._context.Set<CurrencyTransaction>()
|
||||
await uow.Set<CurrencyTransaction>()
|
||||
.DeleteAsync(x => x.UserId == userId);
|
||||
|
||||
// delete user, currency, and clubs go away with it
|
||||
await uow._context.DiscordUser
|
||||
await uow.DiscordUser
|
||||
.DeleteAsync(u => u.UserId == userId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user