using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TMSDAL.DTO.EvaluationResponse
{
///
/// Maps to DBO.TEVALUATIONRESPONSE
/// The filled evaluation form submitted by a respondent for a specific instance.
/// Responses are IMMUTABLE — no update after submission.
/// Submitting a response automatically marks the parent instance as Completed.
/// One response per respondent per instance.
///
public class EvaluationResponseDTO
{
// =====================================================
// PRIMARY KEY
// =====================================================
///
/// Unique identifier for this evaluation response.
/// Auto-generated via AutoNumber — do not set manually on insert.
///
public int EvaluationResponseId { get; set; }
// =====================================================
// BUSINESS COLUMNS — FOREIGN KEYS
// =====================================================
///
/// FK → TEVALUATIONINSTANCE.EVALUATIONINSTANCEID
/// The evaluation instance this response belongs to.
///
public int EvaluationInstanceId { get; set; }
///
/// FK → MEMPLOYEE.EMPLOYEEID
/// The person who filled and submitted this response.
/// May differ from EmployeeId if RespondentType = Supervisor / Manager.
///
public int RespondentId { get; set; }
///
/// Joined from MEMPLOYEE — display reference only.
/// Hidden in response if IsAnonymous = 1.
///
public string? RespondentName { get; set; }
// =====================================================
// BUSINESS COLUMNS — RESPONSE DATA
// =====================================================
///
/// JSON payload containing answers to all template questions.
/// Format: [{ "questionId": 1, "answer": "5" }, { "questionId": 2, "answer": "Strongly Agree" }]
/// Structure mirrors MEVALUATIONTEMPLATE.QUESTIONSJSON question IDs.
/// Required — cannot be empty on submit.
///
public string ResponseDataJson { get; set; } = string.Empty;
///
/// Computed overall rating derived from ResponseDataJson answers.
/// Numeric(3,1) — e.g. 4.5 out of 5.0.
/// Calculated and set by the client or BLL before save.
///
public decimal OverallRating { get; set; } = 0;
///
/// Timestamp when the respondent submitted the form.
/// Set by BLL to DateTime.UtcNow on submit — do not set manually.
///
public DateTime SubmittedOn { get; set; }
///
/// Whether this response should hide the respondent's identity.
/// 0 = No — RespondentName visible to HR/L&D.
/// 1 = Yes — RespondentName hidden; ResponseDataJson still stored.
///
public byte IsAnonymous { get; set; } = 0;
// =====================================================
// 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; }
}
}