diff --git a/Controllers/DisableController.cs b/Controllers/DisableController.cs index 446c397..58264df 100644 --- a/Controllers/DisableController.cs +++ b/Controllers/DisableController.cs @@ -1604,11 +1604,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers r.ExamId = workSheet?.Cells[row, 2]?.GetValue(); - //var recruit = await _context.Disables.AsQueryable() - // .Include(x => x.PeriodExam) - // .Where(x => x.PeriodExam == rec_import && x.ExamId == r.ExamId) - // .FirstOrDefaultAsync(); - // ใช้ dictionary lookup แทน query DB ทีละรอบ if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit)) { @@ -1633,26 +1628,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers r.FullScore = 300; r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue(), 2); - if (workSheet?.Cells[row, 7]?.GetValue() == "ขาดสอบ") - { - r.ExamStatus = "ขส."; - } - else if (workSheet?.Cells[row, 14]?.GetValue() == "ได้") - { - r.ExamStatus = "ผ่าน"; - } - else if (workSheet?.Cells[row, 14]?.GetValue() == "ตก") - { - r.ExamStatus = "ไม่ผ่าน"; - } - else - { - r.ExamStatus = "-"; - } + var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue()?.Trim(); + var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue()?.Trim(); + r.ExamStatus = + examStatusCol7 == "ขาดสอบ" ? "ขส." : + examStatusCol14 == "ได้" ? "ผ่าน" : + examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-"; r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue(); - r.ExamAttribute = (workSheet?.Cells[row, 16]?.GetValue()?.Trim() == "ผ่าน") ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"; + var examAttr = workSheet?.Cells[row, 16]?.GetValue()?.Trim(); + r.ExamAttribute = + examAttr == "ผ่าน" ? "มีคุณสมบัติ" : + examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : ""; r.Major = workSheet.Name; @@ -2098,11 +2086,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers // ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5) // ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ" // : "ไม่มีคุณสมบัติ", - examAttribute = x.score == null - ? "ไม่มีคุณสมบัติ" - : string.IsNullOrEmpty(x.score.ExamAttribute) - ? "ไม่มีคุณสมบัติ" - : x.score.ExamAttribute, + + examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) && + (x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ") + ? x.score.ExamAttribute : "", + remark = x.disable.Remark, isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "", applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue @@ -2227,11 +2215,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers // ? "มีคุณสมบัติ" // : "ไม่มีคุณสมบัติ" // : "ไม่มีคุณสมบัติ", - ExamAttribute = sr == null - ? "ไม่มีคุณสมบัติ" - : string.IsNullOrEmpty(sr.ExamAttribute) - ? "ไม่มีคุณสมบัติ" - : sr.ExamAttribute, + + ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) && + (sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ") + ? sr.ExamAttribute : "", + IsSpecial = p.Isspecial, Remark = p.Remark, University = p.Educations.First().University,