using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TMSDAL.DTO.EvaluationInstance { /// /// Maps to DBO.TEVALUATIONINSTANCE /// One scheduled evaluation event per employee per plan. /// Created when a training completes or a period evaluation is triggered. /// Tracks the lifecycle: Pending → Sent → Completed / Overdue / Cancelled. /// public class EvaluationInstanceDTO { // ===================================================== // PRIMARY KEY // ===================================================== /// /// Unique identifier for this evaluation instance. /// Auto-generated via AutoNumber — do not set manually on insert. /// public int EvaluationInstanceId { get; set; } // ===================================================== // BUSINESS COLUMNS — FOREIGN KEYS // ===================================================== /// /// FK → MEVALUATIONPLAN.EVALUATIONPLANID /// The evaluation plan that governs this instance. /// public int EvaluationPlanId { get; set; } /// /// Joined from MEVALUATIONPLAN — display reference only. /// public string? PlanTitle { get; set; } /// /// FK → MEVALUATIONTEMPLATE.EVALUATIONTEMPLATEID /// The questionnaire template to be filled by the respondent. /// public int EvaluationTemplateId { get; set; } /// /// Joined from MEVALUATIONTEMPLATE — display reference only. /// public string? TemplateTitle { get; set; } /// /// FK → TTRAININGENROLLMENT.ENROLLMENTID /// -1 = Multi-programme period evaluation (not tied to a specific enrollment). /// public int EnrollmentId { get; set; } = -1; /// /// FK → MEMPLOYEE.EMPLOYEEID /// The employee being evaluated. /// public int EmployeeId { get; set; } /// /// Joined from MEMPLOYEE — display reference only. /// public string? EmployeeName { get; set; } /// /// FK → MEMPLOYEE.EMPLOYEEID /// The person responsible for filling the evaluation form. /// -1 = Same as EmployeeId (self-evaluation). /// public int RespondentId { get; set; } = -1; /// /// Joined from MEMPLOYEE — display reference only. /// public string? RespondentName { get; set; } // ===================================================== // BUSINESS COLUMNS — PERIOD & SCHEDULE // ===================================================== /// /// Start of the evaluation coverage period. /// Null for immediate post-training evaluations. /// public DateTime? PeriodCoveredFrom { get; set; } /// /// End of the evaluation coverage period. /// Null for immediate post-training evaluations. /// public DateTime? PeriodCoveredTo { get; set; } /// /// Date by which the evaluation must be completed. /// Computed from EvalWindowDays in MEVALUATIONPLAN. /// public DateTime DueDate { get; set; } // ===================================================== // BUSINESS COLUMNS — STATUS & TRACKING // ===================================================== /// /// Current lifecycle status of this evaluation instance. /// 0 = Pending — created, not yet sent to respondent. /// 1 = Sent — form dispatched to respondent. /// 2 = Completed — response submitted. /// 3 = Overdue — past DueDate with no response. /// 4 = Cancelled — manually cancelled by HR/L&D. /// BLL enforces: always set to 0 on creation. /// public byte EvalStatus { get; set; } = 0; /// /// Number of reminder notifications sent so far. /// Incremented each time a reminder is dispatched. /// public short ReminderSentCount { get; set; } = 0; /// /// Timestamp of the most recent reminder sent. /// Null if no reminder has been sent yet. /// public DateTime? LastReminderSentAt { get; set; } /// /// Timestamp when the respondent submitted their response. /// Null until EvalStatus = 2 (Completed). /// Set automatically by BLL when SubmitEvaluationResponse is called. /// public DateTime? CompletedAt { get; set; } // ===================================================== // STANDARD FIELDS // ===================================================== /// Optimistic concurrency version counter. public short Version { get; set; } /// /// Record status. /// 0 = Inactive, 1 = Active, 2–5 = Custom workflow states. /// public byte Status { get; set; } = 1; /// Display sort order. Default 9999 = append to end. public short SortOrder { get; set; } = 9999; /// /// Source of record creation. /// 1–4 = Import sources, 5 = Manual entry (default). /// public byte SourceType { get; set; } = 5; /// FK → MCLIENT.CLIENTID. Set by BLL from LoginDTO. public int TenantId { get; set; } /// FK → MUSER.USERID. Set by BLL from LoginDTO. public int CreatedById { get; set; } /// Set by BLL to DateTime.UtcNow on insert. public DateTime CreatedOn { get; set; } /// FK → MUSER.USERID. Updated by BLL on every save. public int ModifiedById { get; set; } /// Set by BLL to DateTime.UtcNow on every save. public DateTime ModifiedOn { get; set; } } }