deleting a GW2Account now updates the discord message
This commit is contained in:
parent
21ac2db1cd
commit
a84cba196b
1 changed files with 8 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
using Lieb.Models;
|
||||
using Lieb.Models.GuildWars2;
|
||||
using Lieb.Models.GuildWars2.Raid;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Lieb.Data
|
||||
|
@ -64,7 +65,9 @@ namespace Lieb.Data
|
|||
if (account != null)
|
||||
{
|
||||
context.Equipped.RemoveRange(account.EquippedBuilds);
|
||||
context.RaidSignUps.RemoveRange(context.RaidSignUps.Where(s => s.GuildWars2AccountId == accountId));
|
||||
IEnumerable<RaidSignUp> signUpsToDelete = context.RaidSignUps.Where(s => s.GuildWars2AccountId == accountId);
|
||||
HashSet<int> raidsToUpdate = signUpsToDelete.Select(s => s.RaidId).ToHashSet();
|
||||
context.RaidSignUps.RemoveRange(signUpsToDelete);
|
||||
await context.SaveChangesAsync();
|
||||
context.GuildWars2Accounts.Remove(account);
|
||||
LiebUser? user = context.LiebUsers.Include(u => u.GuildWars2Accounts).FirstOrDefault(u => u.GuildWars2Accounts.Contains(account));
|
||||
|
@ -76,6 +79,10 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
await _discordService.RenameUser(user.Id, user.Name, newMain.AccountName);
|
||||
}
|
||||
foreach(int raidId in raidsToUpdate)
|
||||
{
|
||||
await _discordService.PostRaidMessage(raidId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue