19b7a9a473
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>
125 lines
4.5 KiB
C#
125 lines
4.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace PowderCoating.Application.DTOs.Equipment;
|
|
|
|
public class EquipmentDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string EquipmentName { get; set; } = string.Empty;
|
|
public string? EquipmentNumber { get; set; }
|
|
public string EquipmentType { get; set; } = string.Empty;
|
|
public string? Manufacturer { get; set; }
|
|
public string? Model { get; set; }
|
|
public string? SerialNumber { get; set; }
|
|
|
|
public DateTime? PurchaseDate { get; set; }
|
|
public decimal PurchasePrice { get; set; }
|
|
public DateTime? WarrantyExpiration { get; set; }
|
|
|
|
public string Status { get; set; } = string.Empty;
|
|
public string StatusDisplay { get; set; } = string.Empty;
|
|
public string? Location { get; set; }
|
|
|
|
public int? RecommendedMaintenanceIntervalDays { get; set; }
|
|
public DateTime? LastMaintenanceDate { get; set; }
|
|
public DateTime? NextScheduledMaintenance { get; set; }
|
|
public int? DaysUntilMaintenance { get; set; }
|
|
|
|
public string? Notes { get; set; }
|
|
public bool IsActive { get; set; }
|
|
|
|
// Manual file information
|
|
public string? ManualFilePath { get; set; }
|
|
public string? ManualFileName { get; set; }
|
|
public long? ManualFileSize { get; set; }
|
|
public string? ManualContentType { get; set; }
|
|
public DateTime? ManualUploadedDate { get; set; }
|
|
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime? UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class EquipmentListDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string EquipmentName { get; set; } = string.Empty;
|
|
public string? EquipmentNumber { get; set; }
|
|
public string EquipmentType { get; set; } = string.Empty;
|
|
public string Status { get; set; } = string.Empty;
|
|
public string StatusDisplay { get; set; } = string.Empty;
|
|
public string? Location { get; set; }
|
|
public DateTime? NextScheduledMaintenance { get; set; }
|
|
public bool IsActive { get; set; }
|
|
}
|
|
|
|
public class CreateEquipmentDto
|
|
{
|
|
[Required(ErrorMessage = "Equipment name is required")]
|
|
[StringLength(200, ErrorMessage = "Equipment name cannot exceed 200 characters")]
|
|
[Display(Name = "Equipment Name")]
|
|
public string EquipmentName { get; set; } = string.Empty;
|
|
|
|
[StringLength(50, ErrorMessage = "Equipment number cannot exceed 50 characters")]
|
|
[Display(Name = "Equipment Number")]
|
|
public string? EquipmentNumber { get; set; }
|
|
|
|
[Required(ErrorMessage = "Equipment type is required")]
|
|
[StringLength(100, ErrorMessage = "Equipment type cannot exceed 100 characters")]
|
|
[Display(Name = "Equipment Type")]
|
|
public string EquipmentType { get; set; } = string.Empty;
|
|
|
|
[StringLength(100, ErrorMessage = "Manufacturer cannot exceed 100 characters")]
|
|
[Display(Name = "Manufacturer")]
|
|
public string? Manufacturer { get; set; }
|
|
|
|
[StringLength(100, ErrorMessage = "Model cannot exceed 100 characters")]
|
|
[Display(Name = "Model")]
|
|
public string? Model { get; set; }
|
|
|
|
[StringLength(100, ErrorMessage = "Serial number cannot exceed 100 characters")]
|
|
[Display(Name = "Serial Number")]
|
|
public string? SerialNumber { get; set; }
|
|
|
|
[Display(Name = "Purchase Date")]
|
|
public DateTime? PurchaseDate { get; set; }
|
|
|
|
[Range(0, 9999999.99, ErrorMessage = "Purchase price must be between 0 and 9,999,999.99")]
|
|
[Display(Name = "Purchase Price")]
|
|
public decimal PurchasePrice { get; set; }
|
|
|
|
[Display(Name = "Warranty Expiration")]
|
|
public DateTime? WarrantyExpiration { get; set; }
|
|
|
|
[Required(ErrorMessage = "Status is required")]
|
|
[StringLength(50, ErrorMessage = "Status cannot exceed 50 characters")]
|
|
[Display(Name = "Status")]
|
|
public string Status { get; set; } = "Operational";
|
|
|
|
[StringLength(200, ErrorMessage = "Location cannot exceed 200 characters")]
|
|
[Display(Name = "Location")]
|
|
public string? Location { get; set; }
|
|
|
|
[Range(1, 3650, ErrorMessage = "Maintenance interval must be between 1 and 3650 days")]
|
|
[Display(Name = "Recommended Maintenance Interval (Days)")]
|
|
public int? RecommendedMaintenanceIntervalDays { get; set; }
|
|
|
|
[Display(Name = "Last Maintenance Date")]
|
|
public DateTime? LastMaintenanceDate { get; set; }
|
|
|
|
[Display(Name = "Next Scheduled Maintenance")]
|
|
public DateTime? NextScheduledMaintenance { get; set; }
|
|
|
|
[StringLength(2000, ErrorMessage = "Notes cannot exceed 2000 characters")]
|
|
[Display(Name = "Notes")]
|
|
public string? Notes { get; set; }
|
|
}
|
|
|
|
public class UpdateEquipmentDto : CreateEquipmentDto
|
|
{
|
|
[Required]
|
|
public int Id { get; set; }
|
|
|
|
[Display(Name = "Active")]
|
|
public bool IsActive { get; set; }
|
|
}
|