fixed crash when deleting Raids
removed Raid from Reminders and DiscordMessages
This commit is contained in:
parent
5d429ff90f
commit
893ec1f16d
11 changed files with 825 additions and 47 deletions
|
@ -196,16 +196,6 @@ namespace Lieb.Data
|
|||
context.Equipped.AddRange(equippedBuilds);
|
||||
context.SaveChanges();
|
||||
|
||||
var discordMessage = new DiscordRaidMessage()
|
||||
{
|
||||
DiscordChannelId = 666954070388637697,
|
||||
DiscordGuildId = 666953424734257182,
|
||||
DiscordMessageId = 1040355092630614087,
|
||||
RaidId = raid.RaidId
|
||||
};
|
||||
context.DiscordRaidMessages.Add(discordMessage);
|
||||
context.SaveChanges();
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,11 @@ namespace Lieb.Data
|
|||
context.RaidReminders.RemoveRange(raid.Reminders);
|
||||
context.DiscordRaidMessages.RemoveRange(raid.DiscordRaidMessages);
|
||||
await context.SaveChangesAsync();
|
||||
raid.SignUps.Clear();
|
||||
raid.Roles.Clear();
|
||||
raid.RaidLogs.Clear();
|
||||
raid.Reminders.Clear();
|
||||
raid.DiscordRaidMessages.Clear();
|
||||
context.Raids.Remove(raid);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
|
@ -487,8 +492,6 @@ namespace Lieb.Data
|
|||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
List<RaidReminder> reminders = context.RaidReminders
|
||||
.Include(r => r.Raid)
|
||||
.ThenInclude(r => r.SignUps)
|
||||
.Where(r => !r.Sent)
|
||||
.ToList();
|
||||
|
||||
|
@ -498,7 +501,11 @@ namespace Lieb.Data
|
|||
switch(reminder.Type)
|
||||
{
|
||||
case RaidReminder.ReminderType.User:
|
||||
await _discordService.SendUserReminder(reminder, reminder.Raid);
|
||||
Raid raid = context.Raids
|
||||
.Include(r => r.SignUps)
|
||||
.Include(r => r.Reminders)
|
||||
.First(r => r.Reminders.Where(re => re.RaidReminderId == reminder.RaidReminderId).Any());
|
||||
await _discordService.SendUserReminder(reminder, raid);
|
||||
break;
|
||||
case RaidReminder.ReminderType.Channel:
|
||||
await _discordService.SendChannelReminder(reminder);
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace Lieb.Data
|
|||
return context.RaidTemplates
|
||||
.Include(r => r.Roles)
|
||||
.Include(r => r.Reminders)
|
||||
.Include(r => r.DiscordRaidMessages)
|
||||
.Include(r => r.TemplateLogs)
|
||||
.FirstOrDefault(t => t.RaidTemplateId == raidTemplateId);
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,12 @@ namespace Lieb.Data
|
|||
context.RaidRoles.RemoveRange(template.Roles);
|
||||
context.RaidReminders.RemoveRange(template.Reminders);
|
||||
context.DiscordRaidMessages.RemoveRange(template.DiscordRaidMessages);
|
||||
context.RaidLogs.RemoveRange(template.TemplateLogs);
|
||||
await context.SaveChangesAsync();
|
||||
template.Roles.Clear();
|
||||
template.Reminders.Clear();
|
||||
template.DiscordRaidMessages.Clear();
|
||||
template.TemplateLogs.Clear();
|
||||
context.RaidTemplates.Remove(template);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
|
690
Lieb/Migrations/20221129223320_RemovedRaidFromDiscordMessage.Designer.cs
generated
Normal file
690
Lieb/Migrations/20221129223320_RemovedRaidFromDiscordMessage.Designer.cs
generated
Normal file
|
@ -0,0 +1,690 @@
|
|||
// <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("20221129223320_RemovedRaidFromDiscordMessage")]
|
||||
partial class RemovedRaidFromDiscordMessage
|
||||
{
|
||||
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")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lieb.Migrations
|
||||
{
|
||||
public partial class RemovedRaidFromDiscordMessage : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_DiscordRaidMessage_Raid_RaidId",
|
||||
table: "DiscordRaidMessage");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RaidReminder_Raid_RaidId",
|
||||
table: "RaidReminder");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "RaidId",
|
||||
table: "RaidReminder",
|
||||
type: "INTEGER",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "RaidId",
|
||||
table: "DiscordRaidMessage",
|
||||
type: "INTEGER",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_DiscordRaidMessage_Raid_RaidId",
|
||||
table: "DiscordRaidMessage",
|
||||
column: "RaidId",
|
||||
principalTable: "Raid",
|
||||
principalColumn: "RaidId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RaidReminder_Raid_RaidId",
|
||||
table: "RaidReminder",
|
||||
column: "RaidId",
|
||||
principalTable: "Raid",
|
||||
principalColumn: "RaidId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_DiscordRaidMessage_Raid_RaidId",
|
||||
table: "DiscordRaidMessage");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RaidReminder_Raid_RaidId",
|
||||
table: "RaidReminder");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "RaidId",
|
||||
table: "RaidReminder",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "RaidId",
|
||||
table: "DiscordRaidMessage",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_DiscordRaidMessage_Raid_RaidId",
|
||||
table: "DiscordRaidMessage",
|
||||
column: "RaidId",
|
||||
principalTable: "Raid",
|
||||
principalColumn: "RaidId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RaidReminder_Raid_RaidId",
|
||||
table: "RaidReminder",
|
||||
column: "RaidId",
|
||||
principalTable: "Raid",
|
||||
principalColumn: "RaidId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -131,7 +131,7 @@ namespace Lieb.Migrations
|
|||
b.Property<ulong>("DiscordMessageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidId")
|
||||
b.Property<int?>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
|
@ -257,7 +257,7 @@ namespace Lieb.Migrations
|
|||
.HasMaxLength(1000)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("RaidId")
|
||||
b.Property<int?>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
|
@ -533,17 +533,13 @@ namespace Lieb.Migrations
|
|||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||
.WithMany("DiscordRaidMessages")
|
||||
.HasForeignKey("RaidId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("RaidId");
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||
.WithMany("DiscordRaidMessages")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
|
||||
b.Navigation("Raid");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidLog", b =>
|
||||
|
@ -571,17 +567,13 @@ namespace Lieb.Migrations
|
|||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||
.WithMany("Reminders")
|
||||
.HasForeignKey("RaidId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("RaidId");
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||
.WithMany("Reminders")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
|
||||
b.Navigation("Raid");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
|
||||
|
|
|
@ -6,11 +6,6 @@ namespace Lieb.Models.GuildWars2.Raid
|
|||
{
|
||||
public int DiscordRaidMessageId { get; set; }
|
||||
|
||||
public int RaidId { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public Raid Raid { get; set; }
|
||||
|
||||
public ulong DiscordMessageId { get; set; }
|
||||
|
||||
public ulong DiscordChannelId { get; set; }
|
||||
|
|
|
@ -72,16 +72,15 @@ namespace Lieb.Models.GuildWars2.Raid
|
|||
DiscordChannelId = reminder.DiscordChannelId,
|
||||
ReminderTimeUTC = reminder.ReminderTimeUTC,
|
||||
Message = reminder.Message,
|
||||
Sent = reminder.Sent,
|
||||
Sent = false,
|
||||
Type = reminder.Type,
|
||||
RaidId = reminder.RaidId
|
||||
TimeType = reminder.TimeType
|
||||
});
|
||||
}
|
||||
foreach (DiscordRaidMessage message in template.DiscordRaidMessages)
|
||||
{
|
||||
this.DiscordRaidMessages.Add(new DiscordRaidMessage()
|
||||
{
|
||||
RaidId = message.RaidId,
|
||||
DiscordChannelId = message.DiscordChannelId,
|
||||
DiscordGuildId = message.DiscordGuildId
|
||||
});
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
|||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public Raid? Raid { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public RaidTemplate? RaidTemplate { get; set; }
|
||||
|
||||
public static RaidLog CreateRaidLog(ulong userId, Raid raid)
|
||||
|
|
|
@ -39,11 +39,6 @@ namespace Lieb.Models.GuildWars2.Raid
|
|||
public ulong DiscordChannelId { get; set; }
|
||||
|
||||
public bool Sent { get; set; } = false;
|
||||
|
||||
public int RaidId { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public Raid Raid { get; set; }
|
||||
}
|
||||
|
||||
public class StaticRaidReminder : RaidReminder
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
@using System.Security.Claims
|
||||
@using SharedClasses.SharedModels
|
||||
@inject RaidTemplateService RaidTemplateService
|
||||
@inject RaidService RaidService
|
||||
@inject UserService UserService
|
||||
@inject DiscordService DiscordService
|
||||
@inject TimeZoneService TimeZoneService
|
||||
|
@ -289,13 +290,15 @@
|
|||
{
|
||||
if(_template.RaidType != RaidType.Planned)
|
||||
{
|
||||
_template.Roles.Clear();
|
||||
_template.Roles.Add(new RaidRole()
|
||||
if(!_template.Roles.Where(r => r.IsRandomSignUpRole).Any())
|
||||
{
|
||||
Spots = 10,
|
||||
Name = "Random",
|
||||
Description = _template.RaidType.ToString()
|
||||
});
|
||||
_template.Roles.Add(RaidService.CreateRandomSignUpRole(_template.RaidType));
|
||||
}
|
||||
|
||||
foreach(RaidRole role in _template.Roles.Where(r => !r.IsRandomSignUpRole))
|
||||
{
|
||||
_rolesToDelete.Add(role);
|
||||
}
|
||||
}
|
||||
|
||||
if(_template.Roles.Count == 0)
|
||||
|
@ -326,11 +329,13 @@
|
|||
foreach(DynamicRaidReminder reminder in _dynamicReminders)
|
||||
{
|
||||
reminder.ReminderTimeUTC = _template.StartTime - new TimeSpan(reminder.DaysBeforeRaid, reminder.HoursBeforeRaid, reminder.MinutesBeforeRaid, 0);
|
||||
reminder.Sent = true;
|
||||
_template.Reminders.Add(reminder);
|
||||
}
|
||||
foreach(StaticRaidReminder reminder in _staticReminders)
|
||||
{
|
||||
reminder.ReminderTimeUTC = await TimeZoneService.GetUTCDateTime(reminder.ReminderDate.Date + reminder.ReminderTime.TimeOfDay);
|
||||
reminder.Sent = true;
|
||||
_template.Reminders.Add(reminder);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue