fixed deleting users
This commit is contained in:
parent
2246624917
commit
300ab2370f
10 changed files with 815 additions and 14 deletions
|
@ -50,7 +50,7 @@ namespace Lieb.Data
|
|||
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||
}
|
||||
|
||||
public async Task AddOrEditRaid(Raid raid, List<RaidRole> rolesToDelete, List<RaidReminder> remindersToDelete, List<DiscordRaidMessage> messagesToDelete, ulong changedBy)
|
||||
public async Task AddOrEditRaid(Raid raid, List<RaidRole> rolesToDelete, List<RaidReminder> remindersToDelete, List<DiscordRaidMessage> messagesToDelete, ulong? changedBy)
|
||||
{
|
||||
if (raid != null)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Lieb.Data
|
|||
{
|
||||
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(template.TimeZone);
|
||||
DateTime UTCStartTime = TimeZoneInfo.ConvertTimeToUtc(template.StartTime, timeZone);
|
||||
if(UTCStartTime.AddDays(-template.CreateDaysBefore).AddHours(1) < DateTime.UtcNow)
|
||||
if(template.Interval > 0 && UTCStartTime.AddDays(-template.CreateDaysBefore).AddHours(1) < DateTime.UtcNow)
|
||||
{
|
||||
raidTemplateService.CreateRaidFromTemplate(template.RaidTemplateId).Wait();
|
||||
}
|
||||
|
|
|
@ -106,6 +106,29 @@ namespace Lieb.Data
|
|||
public async Task DeleteUser(ulong userId)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
IEnumerable<Raid> raids = context.Raids.Where(r => r.RaidOwnerId == userId);
|
||||
foreach(Raid raid in raids)
|
||||
{
|
||||
raid.RaidOwnerId = null;
|
||||
}
|
||||
IEnumerable<RaidTemplate> templates = context.RaidTemplates.Where(r => r.RaidOwnerId == userId);
|
||||
foreach(RaidTemplate template in templates)
|
||||
{
|
||||
template.RaidOwnerId = null;
|
||||
}
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
IEnumerable<RaidSignUp> signUps = context.RaidSignUps.Where(r => r.LiebUserId == userId);
|
||||
context.RemoveRange(signUps);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
IEnumerable<RaidLog> logs = context.RaidLogs.Where(r => r.UserId == userId);
|
||||
foreach(RaidLog log in logs)
|
||||
{
|
||||
log.UserId = null;
|
||||
}
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
LiebUser user = GetLiebUser(userId);
|
||||
foreach(GuildWars2Account account in user.GuildWars2Accounts)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue