Files
PowderCoatingLogix/src/PowderCoating.Core/Entities/Equipment.cs
T
spouliot 19b7a9a473 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>
2026-05-24 10:38:05 -04:00

83 lines
3.5 KiB
C#

using PowderCoating.Core.Enums;
namespace PowderCoating.Core.Entities;
public class Equipment : BaseEntity
{
public string EquipmentName { get; set; } = string.Empty;
public string? EquipmentNumber { get; set; }
public string EquipmentType { get; set; } = string.Empty; // Oven, Spray Booth, Compressor, etc.
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 EquipmentStatus Status { get; set; } = EquipmentStatus.Operational;
public string? Location { get; set; }
// Maintenance Information
public int? RecommendedMaintenanceIntervalDays { get; set; }
public DateTime? LastMaintenanceDate { get; set; }
public DateTime? NextScheduledMaintenance { get; set; }
public string? Notes { get; set; }
public bool IsActive { get; set; } = true;
// Oven-specific capacity (relevant when EquipmentType == "Oven")
public decimal? MaxLoadSqFt { get; set; }
public int? OvenCycleMinutes { get; set; }
// User Manual
public string? ManualFilePath { get; set; } // Filesystem path: /media/{CompanyId}/equipment-manuals/{equipmentId}/{filename}.pdf
public string? ManualFileName { get; set; } // Original filename
public long? ManualFileSize { get; set; } // File size in bytes
public string? ManualContentType { get; set; } // e.g., "application/pdf"
public DateTime? ManualUploadedDate { get; set; }
// Relationships
public virtual ICollection<MaintenanceRecord> MaintenanceRecords { get; set; } = new List<MaintenanceRecord>();
public virtual ICollection<OvenBatch> OvenBatches { get; set; } = new List<OvenBatch>();
}
public class MaintenanceRecord : BaseEntity
{
public int EquipmentId { get; set; }
public string MaintenanceType { get; set; } = string.Empty; // Preventive, Repair, Inspection, etc.
public MaintenanceStatus Status { get; set; } = MaintenanceStatus.Scheduled;
public MaintenancePriority Priority { get; set; } = MaintenancePriority.Normal;
public DateTime ScheduledDate { get; set; }
public DateTime? CompletedDate { get; set; }
public string? PerformedById { get; set; } // Changed from int? to string? for Identity FK
public string? AssignedUserId { get; set; } // Assigned user
public string Description { get; set; } = string.Empty;
public string? WorkPerformed { get; set; }
public string? PartsReplaced { get; set; }
public decimal LaborCost { get; set; }
public decimal PartsCost { get; set; }
public decimal TotalCost { get; set; }
public decimal DowntimeHours { get; set; }
public string? Notes { get; set; }
public string? TechnicianNotes { get; set; }
// Recurrence
public bool IsRecurring { get; set; }
public MaintenanceRecurrenceFrequency? RecurrenceFrequency { get; set; }
public DateTime? RecurrenceEndDate { get; set; }
public string? RecurrenceGroupId { get; set; } // GUID string groups all occurrences in a series
public int? RecurrenceParentId { get; set; } // null on parent; child → parent.Id
// Relationships
public virtual Equipment Equipment { get; set; } = null!;
public virtual ApplicationUser? PerformedBy { get; set; }
public virtual ApplicationUser? AssignedUser { get; set; }
public virtual MaintenanceRecord? RecurrenceParent { get; set; }
}