using System; using System.Collections.Generic; namespace LCU.Library.Internal.IncentiveApiModels.Results { public class ActiveEmployeeResult { public ActiveEmployeeResult(IReadOnlyDictionary row) { DisplayName = row["Employee_DisplayName"]; EmployeeNumber = row["EmployeeEmploymentStatus_EmployeeNumber"]; var hireDate = row["Employee_HireDate"]; HireDate = string.IsNullOrWhiteSpace(hireDate) ? DateTime.Now : DateTime.Parse(hireDate); LoginName = row["IdLibrary_LoginName"]; if (row.ContainsKey("EmployeeManager_ManagerEmployeeNumber")) { ManagerKey = row["EmployeeManager_ManagerEmployeeNumber"]; } OrgCode = row["OrgUnit_LedgerCode"]; OrgUnit = row["OrgUnit_ShortName"]; Role = row["Job_ShortName"]; Status = row["EmploymentStatus_ShortName"]; } public string DisplayName { get; } public string EmployeeNumber { get; } public DateTime HireDate { get; } public string LoginName { get; } public string? ManagerKey { get; } public string OrgCode { get; } public string OrgUnit { get; } public string Role { get; } public string Status { get; } public bool CanProcess() { return !string.IsNullOrWhiteSpace(EmployeeNumber) && !string.IsNullOrWhiteSpace(LoginName) && !string.IsNullOrWhiteSpace(OrgUnit) && !string.IsNullOrWhiteSpace(Role) && !string.IsNullOrWhiteSpace(Status) && Status == "Active"; } public string GetDnaOrgCode() { return "1" + OrgCode; } public DateTime DetermineHireDate() { if (HireDate != DateTime.MinValue) { return HireDate; } return new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); } } }