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());
|
.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)
|
if (raid != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Lieb.Data
|
||||||
{
|
{
|
||||||
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(template.TimeZone);
|
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(template.TimeZone);
|
||||||
DateTime UTCStartTime = TimeZoneInfo.ConvertTimeToUtc(template.StartTime, 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();
|
raidTemplateService.CreateRaidFromTemplate(template.RaidTemplateId).Wait();
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,29 @@ namespace Lieb.Data
|
||||||
public async Task DeleteUser(ulong userId)
|
public async Task DeleteUser(ulong userId)
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
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);
|
LiebUser user = GetLiebUser(userId);
|
||||||
foreach(GuildWars2Account account in user.GuildWars2Accounts)
|
foreach(GuildWars2Account account in user.GuildWars2Accounts)
|
||||||
{
|
{
|
||||||
|
|
688
Lieb/Migrations/20221203143537_RaidOwnerNullable.Designer.cs
generated
Normal file
688
Lieb/Migrations/20221203143537_RaidOwnerNullable.Designer.cs
generated
Normal file
|
@ -0,0 +1,688 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Lieb.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Lieb.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(LiebContext))]
|
||||||
|
[Migration("20221203143537_RaidOwnerNullable")]
|
||||||
|
partial class RaidOwnerNullable
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.DiscordSettings", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("DiscordSettingsId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("ChangeUserNames")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordLogChannel")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("DiscordSettingsId");
|
||||||
|
|
||||||
|
b.ToTable("DiscordSettings", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EquippedId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("CanTank")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("GuildWars2AccountId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("GuildWars2BuildId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("EquippedId");
|
||||||
|
|
||||||
|
b.HasIndex("GuildWars2AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("GuildWars2BuildId");
|
||||||
|
|
||||||
|
b.ToTable("Equipped", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("GuildWars2AccountId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("AccountName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ApiKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<ulong?>("LiebUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("GuildWars2AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("LiebUserId");
|
||||||
|
|
||||||
|
b.ToTable("GuildWars2Account", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("GuildWars2BuildId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<short>("Alacrity")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("BuildName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(60)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Class")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("EliteSpecialization")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<short>("Heal")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<short>("Might")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<short>("Quickness")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("GuildWars2BuildId");
|
||||||
|
|
||||||
|
b.ToTable("GuildWars2Build", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("DiscordRaidMessageId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordChannelId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordGuildId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordMessageId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidTemplateId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("DiscordRaidMessageId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidTemplateId");
|
||||||
|
|
||||||
|
b.ToTable("DiscordRaidMessage", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("EndTimeUTC")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("FreeForAllTimeUTC")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Guild")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("MoveFlexUsers")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Organizer")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<ulong?>("RaidOwnerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("RaidType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("RequiredRole")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("StartTimeUTC")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("VoiceChat")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("RaidId");
|
||||||
|
|
||||||
|
b.ToTable("Raid", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidLog", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidLogId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("LogEntry")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidTemplateId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Time")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong?>("UserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("RaidLogId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidTemplateId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RaidLog", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidReminderId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordChannelId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("DiscordServerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Message")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidTemplateId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ReminderTimeUTC")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("Sent")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("TimeType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("RaidReminderId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidTemplateId");
|
||||||
|
|
||||||
|
b.ToTable("RaidReminder", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidRoleId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRandomSignUpRole")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(40)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("RaidTemplateId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Spots")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("RaidRoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidTemplateId");
|
||||||
|
|
||||||
|
b.ToTable("RaidRole", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidSignUpId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ExternalUserName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("GuildWars2AccountId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong?>("LiebUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("RaidId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("RaidRoleId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("SignUpType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("RaidSignUpId");
|
||||||
|
|
||||||
|
b.HasIndex("GuildWars2AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("LiebUserId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidId");
|
||||||
|
|
||||||
|
b.HasIndex("RaidRoleId");
|
||||||
|
|
||||||
|
b.ToTable("RaidSignUp", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RaidTemplateId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CreateDaysBefore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EndTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("FreeForAllTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Guild")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Interval")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("MoveFlexUsers")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Organizer")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<ulong?>("RaidOwnerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("RaidType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("RequiredRole")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("TimeZone")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("VoiceChat")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("RaidTemplateId");
|
||||||
|
|
||||||
|
b.ToTable("RaidTemplate", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.LiebRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("LiebRoleId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Level")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("LevelToAssign")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("RoleName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(40)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("LiebRoleId");
|
||||||
|
|
||||||
|
b.ToTable("LiebRole", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.LiebUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("AlwaysSignUpWithMainAccount")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("BannedUntil")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("Birthday")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("MainGW2Account")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(40)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Pronouns")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(60)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("LiebUser", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("RoleAssignmentId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("LiebRoleId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("LiebUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("RoleAssignmentId");
|
||||||
|
|
||||||
|
b.HasIndex("LiebRoleId");
|
||||||
|
|
||||||
|
b.HasIndex("LiebUserId");
|
||||||
|
|
||||||
|
b.ToTable("RoleAssignment", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
|
||||||
|
.WithMany("EquippedBuilds")
|
||||||
|
.HasForeignKey("GuildWars2AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Build", "GuildWars2Build")
|
||||||
|
.WithMany("EquippedRoles")
|
||||||
|
.HasForeignKey("GuildWars2BuildId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("GuildWars2Account");
|
||||||
|
|
||||||
|
b.Navigation("GuildWars2Build");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.LiebUser", null)
|
||||||
|
.WithMany("GuildWars2Accounts")
|
||||||
|
.HasForeignKey("LiebUserId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||||
|
.WithMany("DiscordRaidMessages")
|
||||||
|
.HasForeignKey("RaidId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||||
|
.WithMany("DiscordRaidMessages")
|
||||||
|
.HasForeignKey("RaidTemplateId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidLog", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||||
|
.WithMany("RaidLogs")
|
||||||
|
.HasForeignKey("RaidId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", "RaidTemplate")
|
||||||
|
.WithMany("TemplateLogs")
|
||||||
|
.HasForeignKey("RaidTemplateId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.LiebUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("Raid");
|
||||||
|
|
||||||
|
b.Navigation("RaidTemplate");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||||
|
.WithMany("Reminders")
|
||||||
|
.HasForeignKey("RaidId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||||
|
.WithMany("Reminders")
|
||||||
|
.HasForeignKey("RaidTemplateId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||||
|
.WithMany("Roles")
|
||||||
|
.HasForeignKey("RaidId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||||
|
.WithMany("Roles")
|
||||||
|
.HasForeignKey("RaidTemplateId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GuildWars2AccountId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.LiebUser", "LiebUser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("LiebUserId");
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||||
|
.WithMany("SignUps")
|
||||||
|
.HasForeignKey("RaidId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidRole", "RaidRole")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RaidRoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("GuildWars2Account");
|
||||||
|
|
||||||
|
b.Navigation("LiebUser");
|
||||||
|
|
||||||
|
b.Navigation("Raid");
|
||||||
|
|
||||||
|
b.Navigation("RaidRole");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Lieb.Models.LiebRole", "LiebRole")
|
||||||
|
.WithMany("RoleAssignments")
|
||||||
|
.HasForeignKey("LiebRoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Lieb.Models.LiebUser", "LiebUser")
|
||||||
|
.WithMany("RoleAssignments")
|
||||||
|
.HasForeignKey("LiebUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("LiebRole");
|
||||||
|
|
||||||
|
b.Navigation("LiebUser");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EquippedBuilds");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EquippedRoles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DiscordRaidMessages");
|
||||||
|
|
||||||
|
b.Navigation("RaidLogs");
|
||||||
|
|
||||||
|
b.Navigation("Reminders");
|
||||||
|
|
||||||
|
b.Navigation("Roles");
|
||||||
|
|
||||||
|
b.Navigation("SignUps");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DiscordRaidMessages");
|
||||||
|
|
||||||
|
b.Navigation("Reminders");
|
||||||
|
|
||||||
|
b.Navigation("Roles");
|
||||||
|
|
||||||
|
b.Navigation("TemplateLogs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.LiebRole", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("RoleAssignments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Lieb.Models.LiebUser", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("GuildWars2Accounts");
|
||||||
|
|
||||||
|
b.Navigation("RoleAssignments");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
Lieb/Migrations/20221203143537_RaidOwnerNullable.cs
Normal file
92
Lieb/Migrations/20221203143537_RaidOwnerNullable.cs
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Lieb.Migrations
|
||||||
|
{
|
||||||
|
public partial class RaidOwnerNullable : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RaidLog_LiebUser_UserId",
|
||||||
|
table: "RaidLog");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "RaidOwnerId",
|
||||||
|
table: "RaidTemplate",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "RaidLog",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "RaidOwnerId",
|
||||||
|
table: "Raid",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RaidLog_LiebUser_UserId",
|
||||||
|
table: "RaidLog",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "LiebUser",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RaidLog_LiebUser_UserId",
|
||||||
|
table: "RaidLog");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "RaidOwnerId",
|
||||||
|
table: "RaidTemplate",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0ul,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "RaidLog",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0ul,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<ulong>(
|
||||||
|
name: "RaidOwnerId",
|
||||||
|
table: "Raid",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0ul,
|
||||||
|
oldClrType: typeof(ulong),
|
||||||
|
oldType: "INTEGER",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RaidLog_LiebUser_UserId",
|
||||||
|
table: "RaidLog",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "LiebUser",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -176,7 +176,7 @@ namespace Lieb.Migrations
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<ulong>("RaidOwnerId")
|
b.Property<ulong?>("RaidOwnerId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<int>("RaidType")
|
b.Property<int>("RaidType")
|
||||||
|
@ -226,7 +226,7 @@ namespace Lieb.Migrations
|
||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<ulong>("UserId")
|
b.Property<ulong?>("UserId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.HasKey("RaidLogId");
|
b.HasKey("RaidLogId");
|
||||||
|
@ -395,7 +395,7 @@ namespace Lieb.Migrations
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<ulong>("RaidOwnerId")
|
b.Property<ulong?>("RaidOwnerId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<int>("RaidType")
|
b.Property<int>("RaidType")
|
||||||
|
@ -554,9 +554,7 @@ namespace Lieb.Migrations
|
||||||
|
|
||||||
b.HasOne("Lieb.Models.LiebUser", "User")
|
b.HasOne("Lieb.Models.LiebUser", "User")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Raid");
|
b.Navigation("Raid");
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
|
|
||||||
public bool MoveFlexUsers { get; set; } = true;
|
public bool MoveFlexUsers { get; set; } = true;
|
||||||
|
|
||||||
public ulong RaidOwnerId { get; set; }
|
public ulong? RaidOwnerId { get; set; }
|
||||||
|
|
||||||
//role name, number of spots
|
//role name, number of spots
|
||||||
public ICollection<RaidRole> Roles { get; set; } = new HashSet<RaidRole>();
|
public ICollection<RaidRole> Roles { get; set; } = new HashSet<RaidRole>();
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
|
|
||||||
public LogType Type {get; set;}
|
public LogType Type {get; set;}
|
||||||
|
|
||||||
public ulong UserId {get; set;}
|
public ulong? UserId {get; set;}
|
||||||
|
|
||||||
public int? RaidId { get; set; }
|
public int? RaidId { get; set; }
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
|
|
||||||
public DateTimeOffset Time { get; set; } = DateTimeOffset.UtcNow;
|
public DateTimeOffset Time { get; set; } = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
public LiebUser User {get; set;}
|
public LiebUser? User {get; set;}
|
||||||
|
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||||
public Raid? Raid { get; set; }
|
public Raid? Raid { get; set; }
|
||||||
|
@ -35,7 +35,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||||
public RaidTemplate? RaidTemplate { get; set; }
|
public RaidTemplate? RaidTemplate { get; set; }
|
||||||
|
|
||||||
public static RaidLog CreateRaidLog(ulong userId, Raid raid)
|
public static RaidLog CreateRaidLog(ulong? userId, Raid raid)
|
||||||
{
|
{
|
||||||
return new RaidLog()
|
return new RaidLog()
|
||||||
{
|
{
|
||||||
|
|
|
@ -296,7 +296,7 @@
|
||||||
}
|
}
|
||||||
_raid.FreeForAllTimeUTC = await TimeZoneService.GetUTCDateTime(_freeForAllDate.Date + _freeForAllTime.TimeOfDay);
|
_raid.FreeForAllTimeUTC = await TimeZoneService.GetUTCDateTime(_freeForAllDate.Date + _freeForAllTime.TimeOfDay);
|
||||||
|
|
||||||
if (_raid.RaidOwnerId == 0)
|
if (!_raid.RaidOwnerId.HasValue)
|
||||||
{
|
{
|
||||||
_raid.RaidOwnerId = _user.Id;
|
_raid.RaidOwnerId = _user.Id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,7 @@
|
||||||
}
|
}
|
||||||
_template.FreeForAllTime = _freeForAllDate.Date + _freeForAllTime.TimeOfDay;
|
_template.FreeForAllTime = _freeForAllDate.Date + _freeForAllTime.TimeOfDay;
|
||||||
|
|
||||||
if (_template.RaidOwnerId == 0)
|
if (!_template.RaidOwnerId.HasValue)
|
||||||
{
|
{
|
||||||
_template.RaidOwnerId = _user.Id;
|
_template.RaidOwnerId = _user.Id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue