Fix equipment creation blocked by maintenance interval validation

RecommendedMaintenanceIntervalDays was a non-nullable int with [Range(1,3650)],
so submitting the form without filling it in bound to 0 and failed validation.
Made nullable on the entity, both DTOs, and the one controller callsite that
calls .AddDays() (now uses .Value). Migration applied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 10:38:05 -04:00
parent e443457139
commit 19b7a9a473
6 changed files with 10759 additions and 8 deletions
@@ -20,7 +20,7 @@ public class EquipmentDto
public string StatusDisplay { get; set; } = string.Empty;
public string? Location { get; set; }
public int RecommendedMaintenanceIntervalDays { get; set; }
public int? RecommendedMaintenanceIntervalDays { get; set; }
public DateTime? LastMaintenanceDate { get; set; }
public DateTime? NextScheduledMaintenance { get; set; }
public int? DaysUntilMaintenance { get; set; }
@@ -101,7 +101,7 @@ public class CreateEquipmentDto
[Range(1, 3650, ErrorMessage = "Maintenance interval must be between 1 and 3650 days")]
[Display(Name = "Recommended Maintenance Interval (Days)")]
public int RecommendedMaintenanceIntervalDays { get; set; }
public int? RecommendedMaintenanceIntervalDays { get; set; }
[Display(Name = "Last Maintenance Date")]
public DateTime? LastMaintenanceDate { get; set; }