/// /// Log table — append-only. No UPDATE or DELETE operations. /// namespace TMSDAL.DTO.CertRenewalAlert { /// /// Maps to DBO.LCERTRENEWALALERT /// LOG table — append-only. Records each certificate renewal or expiry alert that was fired. /// Never updated. Never deleted. Never FK-referenced by other tables. /// PK is IDENTITY — do NOT set LCertRenewalAlertId manually on insert. /// One row per alert fired. Multiple rows per certificate are expected. /// public class CertRenewalAlertDTO { // ===================================================== // PRIMARY KEY — IDENTITY // ===================================================== /// /// Auto-generated IDENTITY PK — set by SQL Server, not AutoNumber. /// Do NOT pass this on insert. Read-only after creation. /// public int LCertRenewalAlertId { get; set; } // ===================================================== // BUSINESS COLUMNS — FOREIGN KEY // ===================================================== /// /// FK → TTRAININGCERTIFICATE.TRAININGCERTIFICATEID /// The certificate that triggered this alert. /// Required on every insert. /// public int TrainingCertificateId { get; set; } /// /// Joined from TTRAININGCERTIFICATE — display reference only. /// The unique certificate number e.g. "CERT-2026-00142". /// public string? CertificateNumber { get; set; } /// /// Joined from TTRAININGCERTIFICATE — display reference only. /// The human-readable title of the certificate e.g. "Fire Safety Level 2". /// public string? CertificateTitle { get; set; } // ===================================================== // BUSINESS COLUMNS — ALERT CLASSIFICATION // ===================================================== /// /// Type of alert fired. /// 0 = RenewalReminder — certificate approaching renewal window. /// 1 = ExpiryWarning — certificate close to expiry date. /// 2 = ExpiredNotice — certificate has already expired. /// public byte AlertType { get; set; } /// /// Number of days before expiry when this alert was scheduled. /// 0 = fired on expiry date itself. /// Positive values = days before expiry (e.g. 30, 14, 7, 1). /// public int DaysBeforeExpiry { get; set; } = 0; // ===================================================== // BUSINESS COLUMNS — SCHEDULING & DELIVERY // ===================================================== /// /// When this alert was scheduled to be sent. /// Set at creation time by the scheduling engine. /// public DateTime ScheduledAt { get; set; } /// /// Actual timestamp when the alert was dispatched to recipients. /// Null until AlertStatus transitions to 1 (Sent). /// public DateTime? SentAt { get; set; } /// /// Who receives this alert. /// 0 = Employee only. /// 1 = Supervisor only. /// 2 = HR only. /// 3 = All (Employee + Supervisor + HR). /// public byte RecipientType { get; set; } = 3; /// /// Channel through which the alert is delivered. /// 0 = Email. /// 1 = InApp notification. /// 2 = SMS. /// 3 = All channels. /// public byte AlertChannel { get; set; } = 0; // ===================================================== // BUSINESS COLUMNS — STATUS // ===================================================== /// /// Current delivery status of this alert. /// 0 = Scheduled — queued, not yet sent. /// 1 = Sent — successfully dispatched to recipients. /// 2 = Failed — dispatch attempted but failed (retry may occur). /// 3 = Cancelled — manually cancelled before dispatch. /// public byte AlertStatus { get; set; } = 0; /// /// Timestamp when the recipient acknowledged or dismissed the alert. /// Null if not yet acknowledged or channel does not support acknowledgement. /// public DateTime? AcknowledgedAt { get; set; } // ===================================================== // LOG STANDARD FIELDS // ===================================================== /// /// FK → MUSER.USERID /// The system user or service account that created this log entry. /// Set by BLL from LoginDTO.UserId on insert. /// public int CreatedById { get; set; } /// /// Timestamp when this log entry was created. /// Set by SQL Server DEFAULT GETDATE() — do not set manually. /// public DateTime CreatedOn { get; set; } } }