diff --git a/Lieb/Data/PollService.cs b/Lieb/Data/PollService.cs index 3690e27..fd98d09 100644 --- a/Lieb/Data/PollService.cs +++ b/Lieb/Data/PollService.cs @@ -46,7 +46,7 @@ namespace Lieb.Data .Where(p => p.RaidId == raidId).ToList(); } - public async Task CreatePoll(string question, List options, int raidId) + public async Task CreatePoll(string question, List options, int raidId, bool isAutoPoll = false) { Poll poll = new Poll() { @@ -62,10 +62,10 @@ namespace Lieb.Data Name = option }); } - return await CreatePoll(poll, raidId); + return await CreatePoll(poll, raidId, isAutoPoll); } - public async Task CreatePoll(Poll poll, int raidId) + public async Task CreatePoll(Poll poll, int raidId, bool isAutoPoll = false) { using var context = _contextFactory.CreateDbContext(); Raid? raid = context.Raids @@ -74,12 +74,13 @@ namespace Lieb.Data if (raid == null) return 0; HashSet users = raid.SignUps.Where(s => s.LiebUserId != null && s.IsMessageSignUp).Select(s => (ulong)s.LiebUserId).ToHashSet(); - return await CreatePoll(poll, users, raidId); + return await CreatePoll(poll, users, raidId, isAutoPoll); } - public async Task CreatePoll(Poll poll, HashSet users, int? raidId = null) + public async Task CreatePoll(Poll poll, HashSet users, int? raidId = null, bool isAutoPoll = false) { poll.RaidId = raidId; + poll.IsAutoPoll = isAutoPoll; foreach(ulong user in users) { @@ -170,5 +171,19 @@ namespace Lieb.Data poll.Answers.Remove(answer); await context.SaveChangesAsync(); } + + public async Task DeleteAutoPolls() + { + using var context = _contextFactory.CreateDbContext(); + List polls = context.Polls.ToList(); + + foreach(Poll poll in polls) + { + if((poll.IsAutoPoll && poll.CreatedAt < DateTime.UtcNow.AddDays(-7))) + { + await DeletePoll(poll.PollId); + } + } + } } } diff --git a/Lieb/Data/RaidService.cs b/Lieb/Data/RaidService.cs index 3042df2..45b57fb 100644 --- a/Lieb/Data/RaidService.cs +++ b/Lieb/Data/RaidService.cs @@ -704,7 +704,7 @@ namespace Lieb.Data { raid.MinUserPollId = await _pollService.CreatePoll( "The raid has not the required users, do you want to raid anyway?", - new List() {Constants.Polls.YES, Constants.Polls.NO }, raid.RaidId); + new List() {Constants.Polls.YES, Constants.Polls.NO }, raid.RaidId, true); await context.SaveChangesAsync(); await _discordService.PostRaidMessage(raid.RaidId); } diff --git a/Lieb/Data/TimerService.cs b/Lieb/Data/TimerService.cs index 4d6d6f5..f03ce81 100644 --- a/Lieb/Data/TimerService.cs +++ b/Lieb/Data/TimerService.cs @@ -73,6 +73,10 @@ namespace Lieb.Data scope.ServiceProvider .GetRequiredService(); await userService.DeleteInactiveUsers(); + var pollService = + scope.ServiceProvider + .GetRequiredService(); + await pollService.DeleteAutoPolls(); } } diff --git a/Lieb/Migrations/20230213220614_PollsCreatedAt.Designer.cs b/Lieb/Migrations/20230213220614_PollsCreatedAt.Designer.cs new file mode 100644 index 0000000..40ab6f9 --- /dev/null +++ b/Lieb/Migrations/20230213220614_PollsCreatedAt.Designer.cs @@ -0,0 +1,773 @@ +// +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("20230213220614_PollsCreatedAt")] + partial class PollsCreatedAt + { + 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("DiscordSettingsId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChangeUserNames") + .HasColumnType("INTEGER"); + + b.Property("DiscordLogChannel") + .HasColumnType("INTEGER"); + + b.HasKey("DiscordSettingsId"); + + b.ToTable("DiscordSettings", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b => + { + b.Property("EquippedId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CanTank") + .HasColumnType("INTEGER"); + + b.Property("GuildWars2AccountId") + .HasColumnType("INTEGER"); + + b.Property("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("GuildWars2AccountId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AccountName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ApiKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LiebUserId") + .HasColumnType("INTEGER"); + + b.HasKey("GuildWars2AccountId"); + + b.HasIndex("LiebUserId"); + + b.ToTable("GuildWars2Account", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b => + { + b.Property("GuildWars2BuildId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Alacrity") + .HasColumnType("INTEGER"); + + b.Property("BuildName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.Property("DamageType") + .HasColumnType("INTEGER"); + + b.Property("EliteSpecialization") + .HasColumnType("INTEGER"); + + b.Property("Might") + .HasColumnType("INTEGER"); + + b.Property("Quickness") + .HasColumnType("INTEGER"); + + b.Property("Source") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SourceLink") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UseInRandomRaid") + .HasColumnType("INTEGER"); + + b.HasKey("GuildWars2BuildId"); + + b.ToTable("GuildWars2Build", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b => + { + b.Property("DiscordRaidMessageId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiscordChannelId") + .HasColumnType("INTEGER"); + + b.Property("DiscordGuildId") + .HasColumnType("INTEGER"); + + b.Property("DiscordMessageId") + .HasColumnType("INTEGER"); + + b.Property("RaidId") + .HasColumnType("INTEGER"); + + b.Property("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("RaidId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("EndTimeUTC") + .HasColumnType("TEXT"); + + b.Property("EventType") + .HasColumnType("INTEGER"); + + b.Property("FreeForAllTimeUTC") + .HasColumnType("TEXT"); + + b.Property("Guild") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MinUserDeadLineUTC") + .HasColumnType("TEXT"); + + b.Property("MinUserPollId") + .HasColumnType("INTEGER"); + + b.Property("MinUsers") + .HasColumnType("INTEGER"); + + b.Property("MoveFlexUsers") + .HasColumnType("INTEGER"); + + b.Property("Organizer") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("RaidOwnerId") + .HasColumnType("INTEGER"); + + b.Property("RaidType") + .HasColumnType("INTEGER"); + + b.Property("RequiredRole") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StartTimeUTC") + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("VoiceChat") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("RaidId"); + + b.ToTable("Raid", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b => + { + b.Property("RaidReminderId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiscordChannelId") + .HasColumnType("INTEGER"); + + b.Property("DiscordServerId") + .HasColumnType("INTEGER"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("RaidId") + .HasColumnType("INTEGER"); + + b.Property("RaidTemplateId") + .HasColumnType("INTEGER"); + + b.Property("ReminderTimeUTC") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("RoleType") + .HasColumnType("INTEGER"); + + b.Property("Sent") + .HasColumnType("INTEGER"); + + b.Property("TimeType") + .HasColumnType("INTEGER"); + + b.Property("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("RaidRoleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("IsRandomSignUpRole") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("RaidId") + .HasColumnType("INTEGER"); + + b.Property("RaidTemplateId") + .HasColumnType("INTEGER"); + + b.Property("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("RaidSignUpId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ExternalUserName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GuildWars2AccountId") + .HasColumnType("INTEGER"); + + b.Property("LiebUserId") + .HasColumnType("INTEGER"); + + b.Property("RaidId") + .HasColumnType("INTEGER"); + + b.Property("RaidRoleId") + .HasColumnType("INTEGER"); + + b.Property("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("RaidTemplateId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreateDaysBefore") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("TEXT"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("EventType") + .HasColumnType("INTEGER"); + + b.Property("FreeForAllTime") + .HasColumnType("TEXT"); + + b.Property("Guild") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Interval") + .HasColumnType("INTEGER"); + + b.Property("MinUserDeadLine") + .HasColumnType("TEXT"); + + b.Property("MinUsers") + .HasColumnType("INTEGER"); + + b.Property("MoveFlexUsers") + .HasColumnType("INTEGER"); + + b.Property("Organizer") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("RaidOwnerId") + .HasColumnType("INTEGER"); + + b.Property("RaidType") + .HasColumnType("INTEGER"); + + b.Property("RequiredRole") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.Property("TimeZone") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("VoiceChat") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("RaidTemplateId"); + + b.ToTable("RaidTemplate", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.LiebRole", b => + { + b.Property("LiebRoleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("LevelToAssign") + .HasColumnType("INTEGER"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("LiebRoleId"); + + b.ToTable("LiebRole", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.LiebUser", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("AlwaysSignUpWithMainAccount") + .HasColumnType("INTEGER"); + + b.Property("BannedUntil") + .HasColumnType("TEXT"); + + b.Property("Birthday") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("LastSignUpAt") + .HasColumnType("TEXT"); + + b.Property("MainGW2Account") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("Pronouns") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("ReminderSubscription") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("LiebUser", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.Poll.Poll", b => + { + b.Property("PollId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllowCustomAnswer") + .HasColumnType("INTEGER"); + + b.Property("AnswerType") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("IsAutoPoll") + .HasColumnType("INTEGER"); + + b.Property("Question") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("RaidId") + .HasColumnType("INTEGER"); + + b.HasKey("PollId"); + + b.ToTable("Poll", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.Poll.PollAnswer", b => + { + b.Property("PollAnswerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Answer") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PollId") + .HasColumnType("INTEGER"); + + b.Property("PollOptionId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("PollAnswerId"); + + b.HasIndex("PollId"); + + b.ToTable("PollAnswer", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.Poll.PollOption", b => + { + b.Property("PollOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("PollId") + .HasColumnType("INTEGER"); + + b.HasKey("PollOptionId"); + + b.HasIndex("PollId"); + + b.ToTable("PollOption", (string)null); + }); + + modelBuilder.Entity("Lieb.Models.RoleAssignment", b => + { + b.Property("RoleAssignmentId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LiebRoleId") + .HasColumnType("INTEGER"); + + b.Property("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.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.Poll.PollAnswer", b => + { + b.HasOne("Lieb.Models.Poll.Poll", null) + .WithMany("Answers") + .HasForeignKey("PollId"); + }); + + modelBuilder.Entity("Lieb.Models.Poll.PollOption", b => + { + b.HasOne("Lieb.Models.Poll.Poll", null) + .WithMany("Options") + .HasForeignKey("PollId"); + }); + + 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("Reminders"); + + b.Navigation("Roles"); + + b.Navigation("SignUps"); + }); + + modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b => + { + b.Navigation("DiscordRaidMessages"); + + b.Navigation("Reminders"); + + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Lieb.Models.LiebRole", b => + { + b.Navigation("RoleAssignments"); + }); + + modelBuilder.Entity("Lieb.Models.LiebUser", b => + { + b.Navigation("GuildWars2Accounts"); + + b.Navigation("RoleAssignments"); + }); + + modelBuilder.Entity("Lieb.Models.Poll.Poll", b => + { + b.Navigation("Answers"); + + b.Navigation("Options"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Lieb/Migrations/20230213220614_PollsCreatedAt.cs b/Lieb/Migrations/20230213220614_PollsCreatedAt.cs new file mode 100644 index 0000000..24e5e68 --- /dev/null +++ b/Lieb/Migrations/20230213220614_PollsCreatedAt.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Lieb.Migrations +{ + public partial class PollsCreatedAt : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CreatedAt", + table: "Poll", + type: "TEXT", + nullable: false, + defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); + + migrationBuilder.AddColumn( + name: "IsAutoPoll", + table: "Poll", + type: "INTEGER", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CreatedAt", + table: "Poll"); + + migrationBuilder.DropColumn( + name: "IsAutoPoll", + table: "Poll"); + } + } +} diff --git a/Lieb/Migrations/LiebContextModelSnapshot.cs b/Lieb/Migrations/LiebContextModelSnapshot.cs index 1288a53..c75357b 100644 --- a/Lieb/Migrations/LiebContextModelSnapshot.cs +++ b/Lieb/Migrations/LiebContextModelSnapshot.cs @@ -507,8 +507,15 @@ namespace Lieb.Migrations b.Property("AnswerType") .HasColumnType("INTEGER"); + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("IsAutoPoll") + .HasColumnType("INTEGER"); + b.Property("Question") .IsRequired() + .HasMaxLength(200) .HasColumnType("TEXT"); b.Property("RaidId") @@ -553,6 +560,7 @@ namespace Lieb.Migrations b.Property("Name") .IsRequired() + .HasMaxLength(100) .HasColumnType("TEXT"); b.Property("PollId") diff --git a/Lieb/Models/Poll/Poll.cs b/Lieb/Models/Poll/Poll.cs index e4d83af..fe13b5e 100644 --- a/Lieb/Models/Poll/Poll.cs +++ b/Lieb/Models/Poll/Poll.cs @@ -19,6 +19,7 @@ namespace Lieb.Models.Poll public AnswerType AnswerType {get; set;} public bool AllowCustomAnswer {get; set;} = false; public int? RaidId { get; set; } - + public DateTimeOffset CreatedAt {get; set;} = DateTimeOffset.UtcNow; + public bool IsAutoPoll {get; set;} = false; } }