From 231c05c2a85de5b9ab4858b296ebb1316b4058c4 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 17 Dec 2025 09:35:43 +0700 Subject: [PATCH] fixed --- Controllers/CandidateController.cs | 2 +- Services/CandidateService.cs | 50 +++++++++++++++--------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs index 4d9e7ba..f6852cb 100644 --- a/Controllers/CandidateController.cs +++ b/Controllers/CandidateController.cs @@ -1575,7 +1575,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers { try { - // await _candidateService.CheckCitizen(examId, positionId, item.CitizenId); + await _candidateService.CheckCitizen(examId, positionId, item.CitizenId); return Success(); } diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index fabd363..168755d 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -667,8 +667,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services EditorConfirm = exam.EditorConfirm, Position = candidatePosition == null ? false : true, //CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null ? true : DateOnly.FromDateTime(exam.RegisterStartDate.Value) <= DateOnly.FromDateTime(DateTime.Now) && DateOnly.FromDateTime(exam.RegisterEndDate.Value) >= DateOnly.FromDateTime(DateTime.Now), - CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null - ? true + CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null + ? true : exam.RegisterStartDate.Value <= DateTime.Now && exam.RegisterEndDate.Value >= DateTime.Now, RegisterEndDate = exam.RegisterEndDate, RegisterStartDate = exam.RegisterStartDate, @@ -2282,7 +2282,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services var periodExam = await _context.PeriodExams.AsQueryable() .FirstOrDefaultAsync(x => x.Id == examGuid); - if (periodExam == null) + if (periodExam == null) throw new Exception(GlobalMessages.ExamNotFound); var candidates = await _context.Candidates.AsQueryable() @@ -2594,12 +2594,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Services public async Task CheckCitizen(string examId, string positionId, string citizenId) { - // var exam = await _context.PeriodExams.AsQueryable() - // .Where(p => p.CheckDisability == false) - // .FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId)); + var exam = await _context.PeriodExams.AsQueryable() + .Where(p => p.CheckDisability == false) + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId)); - // if (exam == null) - // throw new Exception(GlobalMessages.ExamNotFound); + if (exam == null) + throw new Exception(GlobalMessages.ExamNotFound); // if (citizenId.Length != 13) // throw new Exception(GlobalMessages.CitizenIncomplete); @@ -2630,27 +2630,27 @@ namespace BMA.EHR.Recurit.Exam.Service.Services // if (citizenIdDigits[12] != chkDigit) // throw new Exception(GlobalMessages.CitizenIncorrect); - // if (positionId != "00000000-0000-0000-0000-000000000000") - // { - // var position = await _context.PositionExams.AsQueryable() - // .FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam); + if (positionId != "00000000-0000-0000-0000-000000000000") + { + var position = await _context.PositionExams.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam); - // if (position == null) - // throw new Exception(GlobalMessages.PositionExamNotFound); + if (position == null) + throw new Exception(GlobalMessages.PositionExamNotFound); - // var candidate1 = await _context.Candidates.AsQueryable() - // .Where(x => x.PeriodExam == exam && x.UserId != UserId /*&& x.PositionExam == position*/ && x.CitizenId == citizenId) - // .FirstOrDefaultAsync(); - // if (candidate1 != null) - // throw new Exception(GlobalMessages.CitizanDupicate); + var candidate1 = await _context.Candidates.AsQueryable() + .Where(x => x.PeriodExam == exam && x.UserId != UserId /*&& x.PositionExam == position*/ && x.CitizenId == citizenId) + .FirstOrDefaultAsync(); + if (candidate1 != null) + throw new Exception(GlobalMessages.CitizanDupicate); return; - // } + } - //var candidate2 = await _context.Candidates.AsQueryable() - // .Where(x => x.PeriodExam == exam && x.UserId != UserId && x.CitizenId == citizenId) - // .FirstOrDefaultAsync(); - //if (candidate2 != null) - // throw new Exception(GlobalMessages.CitizanDupicate); + var candidate2 = await _context.Candidates.AsQueryable() + .Where(x => x.PeriodExam == exam && x.UserId != UserId && x.CitizenId == citizenId) + .FirstOrDefaultAsync(); + if (candidate2 != null) + throw new Exception(GlobalMessages.CitizanDupicate); } public async Task GetExamCandidateAsync(Guid id)