From fe4781030b26fff7153ad7330b511ec90d6ca249 Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 19 Nov 2025 10:31:20 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B8=AA=E0=B8=A3=E0=B8=A3=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=AA=E0=B8=AD=E0=B8=9A=E0=B8=84=E0=B8=B1=E0=B8=94?= =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B8=AD=E0=B8=81=20(4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/CandidateController.cs | 6 ++--- Request/RequestApproveShowExamInfo.cs | 9 +++++++ Response/CandidateResponseItem.cs | 6 ++--- Services/CandidateService.cs | 38 +++++++++++---------------- 4 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 Request/RequestApproveShowExamInfo.cs diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs index 65017c5..224e0c3 100644 --- a/Controllers/CandidateController.cs +++ b/Controllers/CandidateController.cs @@ -830,13 +830,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> CheckShowExamInfoService(RequestApproves item) + public async Task> CheckShowExamInfoService(RequestApproveShowExamInfo item) { try { - if (item.CandidateId != null) + if (!string.IsNullOrEmpty(item.ExamId)) { - await _candidateService.AdminCheckShowExamInfoService(item.CandidateId); + await _candidateService.AdminCheckShowExamInfoService(item.ExamId); } return Success(); diff --git a/Request/RequestApproveShowExamInfo.cs b/Request/RequestApproveShowExamInfo.cs new file mode 100644 index 0000000..b4c5431 --- /dev/null +++ b/Request/RequestApproveShowExamInfo.cs @@ -0,0 +1,9 @@ +using System.Net; + +namespace BMA.EHR.Recurit.Exam.Service.Request +{ + public class RequestApproveShowExamInfo + { + public string? ExamId { get; set; } + } +} diff --git a/Response/CandidateResponseItem.cs b/Response/CandidateResponseItem.cs index bb14cd9..4bb1472 100644 --- a/Response/CandidateResponseItem.cs +++ b/Response/CandidateResponseItem.cs @@ -5,14 +5,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Response { // public Models.Prefix? Prefix { get; set; } public string? PrefixId { get; set; } - public string? PrefixName { get; set; } + public string? PrefixName { get; set; } = string.Empty; public string? FirstName { get; set; } = string.Empty; public string? LastName { get; set; } = string.Empty; public string? Nationality { get; set; } = string.Empty; public DateTime? DateOfBirth { get; set; } // public Models.Relationship? Relationship { get; set; } public string? ReligionId { get; set; } - public string? ReligionName { get; set; } + public string? ReligionName { get; set; } = string.Empty; public string? Email { get; set; } = string.Empty; public string? CitizenId { get; set; } = string.Empty; // public Models.Province? CitizenProvince { get; set; } @@ -88,7 +88,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response public Guid? EducationLevelHighId { get; set; } public Guid? ContactPrefixId { get; set; } - public string? ContactPrefixName { get; set; } + public string? ContactPrefixName { get; set; } = string.Empty; public string? ContactFirstname { get; set; } public string? ContactLastname { get; set; } public string? ContactRelations { get; set; } diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index 229d2e4..811df0e 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -7,6 +7,7 @@ using BMA.EHR.Recurit.Exam.Service.Request; using BMA.EHR.Recurit.Exam.Service.Response; using BMA.EHR.Recurit.Exam.Service.Responses.Document; using Microsoft.EntityFrameworkCore; +using System.Linq; namespace BMA.EHR.Recurit.Exam.Service.Services { @@ -2271,33 +2272,24 @@ namespace BMA.EHR.Recurit.Exam.Service.Services await _context.SaveChangesAsync(); } - public async Task AdminCheckShowExamInfoService(string[] candidateId) + public async Task AdminCheckShowExamInfoService(string examId) { - foreach (var _candidateId in candidateId) - { - var candidate = await _context.Candidates.AsQueryable() + var examGuid = Guid.Parse(examId); + var periodExam = await _context.PeriodExams.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == examGuid); + + if (periodExam == null) + throw new Exception(GlobalMessages.ExamNotFound); + + var candidates = await _context.Candidates.AsQueryable() .Include(x => x.PeriodExam) - .Include(x => x.PositionExam) - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(_candidateId)); - if (candidate == null) - throw new Exception(GlobalMessages.CandidateNotFound); - - if (candidate.Status.Trim().ToUpper() != "CHECKSEAT") - continue; - - if (candidate.PeriodExam == null) - throw new Exception(GlobalMessages.ExamNotFound); - - var periodExam = await _context.Candidates.AsQueryable() - .Where(x => x.PeriodExam == candidate.PeriodExam) - .Where(x => x.PositionExam == candidate.PositionExam) - .Where(x => x.ExamIdenNumber != null) - .Where(x => x.Status != "register") - .OrderByDescending(d => d.CreatedAt) + .Where(x => x.PeriodExam.Id == examGuid && x.IsShowExamInfo == false) .ToListAsync(); - if (periodExam == null) - throw new Exception(GlobalMessages.ExamNotFound); + foreach (var candidate in candidates) + { + if (candidate.Status.Trim().ToUpper() != "CHECKSEAT") + continue; candidate.IsShowExamInfo = true; }