fixed deleting the user
This commit is contained in:
parent
26780fae6e
commit
f9e05ab545
2 changed files with 4 additions and 10 deletions
|
@ -103,17 +103,15 @@ namespace Lieb.Data
|
||||||
await _discordService.RenameUser(user.Id, user.Name, GetMainAccount(user.Id).AccountName);
|
await _discordService.RenameUser(user.Id, user.Name, GetMainAccount(user.Id).AccountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteUser(LiebUser user)
|
public async Task DeleteUser(ulong userId)
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
LiebUser user = GetLiebUser(userId);
|
||||||
foreach(GuildWars2Account account in user.GuildWars2Accounts)
|
foreach(GuildWars2Account account in user.GuildWars2Accounts)
|
||||||
{
|
{
|
||||||
await _guildWars2AccountService.DeleteAccount(account.GuildWars2AccountId);
|
await _guildWars2AccountService.DeleteAccount(account.GuildWars2AccountId);
|
||||||
}
|
}
|
||||||
context.RaidLogs.RemoveRange(context.RaidLogs.Where(r => r.UserId == user.Id).ToList());
|
user.GuildWars2Accounts.Clear();
|
||||||
context.RaidSignUps.RemoveRange(context.RaidSignUps.Where(r => r.LiebUserId == user.Id));
|
|
||||||
context.RoleAssignments.RemoveRange(context.RoleAssignments.Where(r => r.LiebUserId == user.Id));
|
|
||||||
context.Remove(user);
|
context.Remove(user);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,11 +112,7 @@
|
||||||
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure you want to delete this Website Account?\nThis will sign you off in every raid in which you are signed up.");
|
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure you want to delete this Website Account?\nThis will sign you off in every raid in which you are signed up.");
|
||||||
if (confirmed)
|
if (confirmed)
|
||||||
{
|
{
|
||||||
await UserService.DeleteUser(_user);
|
await UserService.DeleteUser(_user.Id);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo("accountedit");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue