diff --git a/Lieb/Data/GuildWars2AccountService.cs b/Lieb/Data/GuildWars2AccountService.cs index 8b49ae4..1595a51 100644 --- a/Lieb/Data/GuildWars2AccountService.cs +++ b/Lieb/Data/GuildWars2AccountService.cs @@ -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 signUpsToDelete = context.RaidSignUps.Where(s => s.GuildWars2AccountId == accountId); + HashSet 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); + } } }