Skip to content

Commit 8e8fba4

Browse files
committed
RE1-T117 PR#409 fixes
1 parent c746a08 commit 8e8fba4

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

Core/Resgrid.Services/CheckInTimerService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ private static void ValidateTimerValues(int timerTargetType, int durationMinutes
554554

555555
if (warningThresholdMinutes < 1)
556556
throw new InvalidOperationException("Check-in timer warning threshold must be at least 1 minute.");
557+
558+
if (warningThresholdMinutes >= durationMinutes)
559+
throw new InvalidOperationException("Check-in timer warning threshold must be less than the duration.");
557560
}
558561

559562
private static HashSet<int> ParseActiveForStates(string activeForStates)

Tests/Resgrid.Tests/Services/CheckInTimerServiceTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ public async Task SaveTimerConfigAsync_Throws_WhenDurationInvalid()
342342
await act.Should().ThrowAsync<InvalidOperationException>();
343343
}
344344

345+
[Test]
346+
public async Task SaveTimerConfigAsync_Throws_WhenWarningThresholdEqualsDuration()
347+
{
348+
var config = new CheckInTimerConfig { DepartmentId = 10, TimerTargetType = 0, DurationMinutes = 30, WarningThresholdMinutes = 30 };
349+
350+
Func<Task> act = async () => await _service.SaveTimerConfigAsync(config);
351+
352+
await act.Should().ThrowAsync<InvalidOperationException>();
353+
}
354+
355+
[Test]
356+
public async Task SaveTimerConfigAsync_Throws_WhenWarningThresholdExceedsDuration()
357+
{
358+
var config = new CheckInTimerConfig { DepartmentId = 10, TimerTargetType = 0, DurationMinutes = 15, WarningThresholdMinutes = 30 };
359+
360+
Func<Task> act = async () => await _service.SaveTimerConfigAsync(config);
361+
362+
await act.Should().ThrowAsync<InvalidOperationException>();
363+
}
364+
345365
[Test]
346366
public async Task SaveTimerConfigAsync_ClearsUnitTypeId_ForNonUnitTypeTargets()
347367
{

Web/Resgrid.Web.Services/Controllers/v4/WeatherAlertsController.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,11 @@ public async Task<ActionResult<GetWeatherAlertSettingsResult>> SaveSettings([Fro
378378
if (entry.StartHour < 0 || entry.StartHour > 23 || entry.EndHour < 0 || entry.EndHour > 24)
379379
return BadRequest("Auto-message schedule hours are invalid: start hour must be 0-23 and end hour must be 0-24.");
380380

381-
// Hours only apply to enabled rows; the window must be non-empty and forward
382-
// (use 0 and 24 for 24-hour delivery)
383-
if (entry.Enabled && entry.EndHour <= entry.StartHour)
384-
return BadRequest("Auto-message schedule end hour must be greater than the start hour. Use start 0 and end 24 for 24-hour delivery.");
381+
// Hours only apply to enabled rows; the window must be non-empty. An end hour
382+
// less than the start hour is a valid overnight window (e.g. 22 to 6); only an
383+
// equal start and end is empty (use 0 and 24 for 24-hour delivery)
384+
if (entry.Enabled && entry.EndHour == entry.StartHour)
385+
return BadRequest("Auto-message schedule window cannot be empty: start hour and end hour must differ. Use start 0 and end 24 for 24-hour delivery.");
385386
}
386387
}
387388

Web/Resgrid.Web/Areas/User/Controllers/DepartmentController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,10 @@ public async Task<IActionResult> SaveCheckInTimerConfig(string configId, int tim
20212021
{
20222022
return BadRequest(ex.Message);
20232023
}
2024+
catch (UnauthorizedAccessException)
2025+
{
2026+
return NotFound();
2027+
}
20242028

20252029
return RedirectToAction("DispatchSettings");
20262030
}

Web/Resgrid.Web/Areas/User/Views/WeatherAlerts/Settings.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="form-group">
6767
<label class="col-sm-4 control-label">@localizer["AutoMessageSeverity"]</label>
6868
<div class="col-sm-8">
69-
<p class="text-muted" style="margin-bottom:10px;">Configure which severity levels generate auto-messages and optionally restrict them to specific hours (department local time). Delivery runs from the start hour up to (but not including) the end hour, so the end hour must be greater than the start hour. Use start 0 and end 24 for 24-hour delivery.</p>
69+
<p class="text-muted" style="margin-bottom:10px;">Configure which severity levels generate auto-messages and optionally restrict them to specific hours (department local time). Delivery runs from the start hour up to (but not including) the end hour. If the start hour is later than the end hour the window wraps overnight &mdash; for example, 18 and 6 delivers from 6pm to 6am. Use start 0 and end 24 for 24-hour delivery.</p>
7070
<table class="table table-bordered" style="max-width:550px;">
7171
<thead>
7272
<tr>

0 commit comments

Comments
 (0)