added copy template function

This commit is contained in:
Sarah Faey 2022-12-08 22:01:54 +01:00
parent 1ac6cc64a6
commit 83f9b2d0b8
4 changed files with 41 additions and 4 deletions

View file

@ -18,7 +18,7 @@ namespace Lieb.Models.GuildWars2.Raid
public Raid() { }
public Raid(RaidTemplate template) : base(template, template.TimeZone)
public Raid(RaidTemplate template) : base(template, template.TimeZone, true)
{
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(template.TimeZone);
StartTimeUTC = TimeZoneInfo.ConvertTimeToUtc(template.StartTime, timeZone);

View file

@ -61,7 +61,7 @@ namespace Lieb.Models.GuildWars2.Raid
public RaidBase() { }
public RaidBase(RaidBase template, string timeZoneString)
public RaidBase(RaidBase template, string timeZoneString, bool convertTimeForRaid)
{
this.Title = template.Title;
this.Description = template.Description;
@ -88,11 +88,17 @@ namespace Lieb.Models.GuildWars2.Raid
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneString);
foreach (RaidReminder reminder in template.Reminders)
{
DateTimeOffset reminderTime = reminder.ReminderTimeUTC;
if(convertTimeForRaid)
{
reminderTime = TimeZoneInfo.ConvertTimeToUtc(reminder.ReminderTimeUTC.DateTime, timeZone);
}
this.Reminders.Add(new RaidReminder()
{
DiscordServerId = reminder.DiscordServerId,
DiscordChannelId = reminder.DiscordChannelId,
ReminderTimeUTC = TimeZoneInfo.ConvertTimeToUtc(reminder.ReminderTimeUTC.DateTime, timeZone),
ReminderTimeUTC = reminderTime,
Message = reminder.Message,
Sent = false,
Type = reminder.Type,

View file

@ -19,5 +19,17 @@ namespace Lieb.Models.GuildWars2.Raid
public int Interval { get; set; }
public int CreateDaysBefore { get; set; }
public RaidTemplate() { }
public RaidTemplate(RaidTemplate template) : base(template, template.TimeZone, false)
{
StartTime = template.StartTime;
EndTime = template.EndTime;
FreeForAllTime = template.FreeForAllTime;
TimeZone = template.TimeZone;
Interval = template.Interval;
CreateDaysBefore = template.CreateDaysBefore;
}
}
}