added multi day raids

This commit is contained in:
Sarah Faey 2023-02-14 20:18:45 +01:00
parent 00a038ae15
commit 922bef0ddf
6 changed files with 131 additions and 25 deletions

View file

@ -69,11 +69,36 @@
<p>
<label>
Date:
<InputDate @bind-Value="_raidDate" />
<InputCheckbox @bind-Value="_isMultiDay" />
Multi day raid
</label>
</p>
@if(_isMultiDay)
{
<p>
<label>
Start date:
<InputDate @bind-Value="_raidDate" />
</label>
</p>
<p>
<label>
End date:
<InputDate @bind-Value="_endDate" />
</label>
</p>
}
else
{
<p>
<label>
Date:
<InputDate @bind-Value="_raidDate" />
</label>
</p>
}
<p>
<label>
Start Time:
@ -209,7 +234,9 @@
private string _errorMessage = string.Empty;
private int _randomSpots = 10;
private bool _isMultiDay = false;
private DateTimeOffset _raidDate = DateTime.Now.Date;
private DateTimeOffset _endDate = DateTime.Now.Date;
private DateTimeOffset _startTime;
private DateTimeOffset _endTime;
private DateTimeOffset _freeForAllDate = DateTime.Now.Date;
@ -260,10 +287,12 @@
_startTime = await TimeZoneService.GetLocalDateTime(_raid.StartTimeUTC);
_endTime = await TimeZoneService.GetLocalDateTime(_raid.EndTimeUTC);
_raidDate = _startTime.Date;
_endDate = _endTime.Date;
_freeForAllTime = await TimeZoneService.GetLocalDateTime(_raid.FreeForAllTimeUTC);
_freeForAllDate = _freeForAllTime.Date;
_minUserDeadlineTime = await TimeZoneService.GetLocalDateTime(_raid.MinUserDeadLineUTC);
_minUserDeadlineDate = _minUserDeadlineTime.Date;
_isMultiDay = _endTime - _startTime > new TimeSpan(24,0,0);
foreach(RaidReminder reminder in _raid.Reminders)
{
if(reminder.TimeType == RaidReminder.ReminderTimeType.Static)
@ -351,8 +380,18 @@
return;
}
if(_isMultiDay && _endDate <= _raidDate)
{
_errorMessage = "The end date has to be after the start date.";
return;
}
_raid.StartTimeUTC = await TimeZoneService.GetUTCDateTime(_raidDate.Date + _startTime.TimeOfDay);
if(_startTime.TimeOfDay <= _endTime.TimeOfDay)
if(_isMultiDay)
{
_raid.EndTimeUTC = await TimeZoneService.GetUTCDateTime(_endDate.Date + _endTime.TimeOfDay);
}
else if(_startTime.TimeOfDay <= _endTime.TimeOfDay)
{
_raid.EndTimeUTC = await TimeZoneService.GetUTCDateTime(_raidDate.Date + _endTime.TimeOfDay);
}

View file

@ -71,11 +71,36 @@
<p>
<label>
Date:
<InputDate @bind-Value="_raidDate" />
<InputCheckbox @bind-Value="_isMultiDay" />
Multi day raid
</label>
</p>
@if(_isMultiDay)
{
<p>
<label>
Start date:
<InputDate @bind-Value="_raidDate" />
</label>
</p>
<p>
<label>
End date:
<InputDate @bind-Value="_endDate" />
</label>
</p>
}
else
{
<p>
<label>
Date:
<InputDate @bind-Value="_raidDate" />
</label>
</p>
}
<p>
<label>
Start Time:
@ -237,7 +262,9 @@
private string _errorMessage = string.Empty;
private int _randomSpots = 10;
private bool _isMultiDay = false;
private DateTimeOffset _raidDate = DateTime.Now.Date;
private DateTimeOffset _endDate = DateTime.Now.Date;
private DateTimeOffset _startTime;
private DateTimeOffset _endTime;
private DateTimeOffset _freeForAllDate = DateTime.Now.Date;
@ -294,10 +321,12 @@
_startTime = _template.StartTime;
_endTime = _template.EndTime;
_raidDate = _startTime.Date;
_endDate = _endTime.Date;
_freeForAllTime = _template.FreeForAllTime;
_freeForAllDate = _freeForAllTime.Date;
_minUserDeadlineTime = _template.MinUserDeadLine;
_minUserDeadlineDate = _minUserDeadlineTime.Date;
_isMultiDay = _endTime - _startTime > new TimeSpan(24,0,0);
foreach(RaidReminder reminder in _template.Reminders)
{
if(reminder.TimeType == RaidReminder.ReminderTimeType.Static)
@ -378,10 +407,20 @@
return;
}
if(_isMultiDay && _endDate <= _raidDate)
{
_errorMessage = "The end date has to be after the start date.";
return;
}
_template.TimeZone = await TimeZoneService.GetUserTimeZone();
_template.StartTime =_raidDate.Date + _startTime.TimeOfDay;
if(_startTime.TimeOfDay <= _endTime.TimeOfDay)
if(_isMultiDay)
{
_template.EndTime = _endDate.Date + _endTime.TimeOfDay;
}
else if(_startTime.TimeOfDay <= _endTime.TimeOfDay)
{
_template.EndTime = _raidDate.Date + _endTime.TimeOfDay;
}

View file

@ -41,14 +41,28 @@
<span class="timesblock">
<span class="times">
<h5>Date</h5>
<p>@_startTime.DateTime.ToLongDateString()</p>
</span>
<span class="times">
<h5>Time</h5>
<p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p>
</span>
@if(_endTime - _startTime > new TimeSpan(24,0,0))
{
<span class="times">
<h5>From</h5>
<p>@_startTime.DateTime.ToLongDateString() @_startTime.DateTime.ToShortTimeString()</p>
</span>
<span class="times">
<h5>To</h5>
<p>@_endTime.DateTime.ToLongDateString() @_endTime.DateTime.ToShortTimeString()</p>
</span>
}
else
{
<span class="times">
<h5>Date</h5>
<p>@_startTime.DateTime.ToLongDateString()</p>
</span>
<span class="times">
<h5>Time</h5>
<p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p>
</span>
}
<span class="times">
<h5>Type</h5>
<p>@_raid.EventType</p>

View file

@ -17,7 +17,7 @@ h5 {
.times {
display: inline-block;
width: 250px;
width: 270px;
padding-top: 15px;
}

View file

@ -16,14 +16,28 @@
<label style="white-space: pre-line">@_template.Description</label>
<span class="timesblock">
<div class="times">
<h5>Date</h5>
<p>@_template.StartTime.ToLongDateString()</p>
</div>
<div class="times">
<h5>Time</h5>
<p>from: @_template.StartTime.ToShortTimeString() to: @_template.EndTime.ToShortTimeString()</p>
</div>
@if(_template.EndTime - _template.StartTime > new TimeSpan(24,0,0))
{
<span class="times">
<h5>From</h5>
<p>@_template.StartTime.ToLongDateString() @_template.StartTime.ToShortTimeString()</p>
</span>
<span class="times">
<h5>To</h5>
<p>@_template.EndTime.ToLongDateString() @_template.EndTime.ToShortTimeString()</p>
</span>
}
else
{
<div class="times">
<h5>Date</h5>
<p>@_template.StartTime.ToLongDateString()</p>
</div>
<div class="times">
<h5>Time</h5>
<p>from: @_template.StartTime.ToShortTimeString() to: @_template.EndTime.ToShortTimeString()</p>
</div>
}
<div class="times">
<h5>TimeZone</h5>
<p>@_template.TimeZone</p>

View file

@ -18,7 +18,7 @@ h5 {
.times {
display: inline-block;
width: 250px;
width: 270px;
padding-top: 15px;
}