From 974211893a7cf73160b247b9b6758fccd2e36cdd Mon Sep 17 00:00:00 2001 From: Kittapath Date: Mon, 2 Oct 2023 11:40:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B8=A3=E0=B8=A7=E0=B8=88=E0=B8=AA?= =?UTF-8?q?=E0=B8=AD=E0=B8=9A=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9?= =?UTF-8?q?=E0=B8=A5=E0=B8=AA=E0=B8=A1=E0=B8=B1=E0=B8=84=E0=B8=A3=E0=B8=AA?= =?UTF-8?q?=E0=B8=AD=E0=B8=9A=E0=B8=AB=E0=B8=A5=E0=B8=B2=E0=B8=A2=E0=B8=84?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/CandidateController.cs | 31 +++++++++++++++++ Request/RequestApproves.cs | 9 +++++ Services/CandidateService.cs | 53 ++++++++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 Request/RequestApproves.cs diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs index 9cc2361..1b0ee72 100644 --- a/Controllers/CandidateController.cs +++ b/Controllers/CandidateController.cs @@ -717,6 +717,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers } } + /// + /// เจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครหลายคน + /// + /// รหัสใบสมัคร + /// + /// เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("check-registers")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> CheckRegistersCandidateService(RequestApproves item) + { + try + { + var _item = new RequestApprove(); + + if (item.CandidateId != null) + { + await _candidateService.AdminCheckCandidatesService(item.CandidateId); + } + + return Success(); + } + catch (Exception ex) + { + return Error(ex); + } + } + /// /// เจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครไม่ผ่านและให้สมัครใหม่ /// diff --git a/Request/RequestApproves.cs b/Request/RequestApproves.cs new file mode 100644 index 0000000..aff1968 --- /dev/null +++ b/Request/RequestApproves.cs @@ -0,0 +1,9 @@ +using System.Net; + +namespace BMA.EHR.Recurit.Exam.Service.Request +{ + public class RequestApproves + { + public string[]? CandidateId { get; set; } + } +} diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index 679a2aa..4517a07 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -630,6 +630,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (exam == null) throw new Exception(GlobalMessages.ExamNotFound); + if (exam.RegisterStartDate != null && exam.RegisterStartDate.Value.Date > DateTime.Now.Date) + throw new Exception("ยังไม่ถึงช่วงเวลาสมัครสอบ"); + + if (exam.RegisterEndDate != null && exam.RegisterEndDate.Value.Date < DateTime.Now.Date) + throw new Exception("หมดเวลาช่วงสมัครสอบ"); + var _candidate = await _context.Candidates.AsQueryable() .FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId); @@ -1729,10 +1735,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (exam == null) throw new Exception(GlobalMessages.ExamNotFound); - if (exam.RegisterStartDate != null && exam.RegisterStartDate.Value.Date < DateTime.Now.Date) + if (exam.RegisterStartDate != null && exam.RegisterStartDate.Value.Date > DateTime.Now.Date) throw new Exception("ยังไม่ถึงช่วงเวลาสมัครสอบ"); - if (exam.RegisterEndDate != null && exam.RegisterEndDate.Value.Date > DateTime.Now.Date) + if (exam.RegisterEndDate != null && exam.RegisterEndDate.Value.Date < DateTime.Now.Date) throw new Exception("หมดเวลาช่วงสมัครสอบ"); var candidate = await _context.Candidates.AsQueryable() @@ -1850,6 +1856,49 @@ namespace BMA.EHR.Recurit.Exam.Service.Services await _context.SaveChangesAsync(); } + public async Task AdminCheckCandidatesService(string[] candidateId) + { + var _num = 0; + foreach (var _candidateId in candidateId) + { + var candidate = await _context.Candidates.AsQueryable() + .Include(x => x.PeriodExam) + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(_candidateId)); + if (candidate == null) + throw new Exception(GlobalMessages.CandidateNotFound); + + if (candidate.PeriodExam == null) + throw new Exception(GlobalMessages.ExamNotFound); + + var periodExam = await _context.Candidates.AsQueryable() + .Where(x => x.PeriodExam == candidate.PeriodExam && x.ExamIdenNumber != null) + .OrderByDescending(d => d.CreatedAt) + .ToListAsync(); + + if (periodExam == null) + throw new Exception(GlobalMessages.ExamNotFound); + + candidate.Status = "payment"; + if (candidate.PeriodExam.Fee == 0) + { + var subject = "แจ้งผลการสมัครสอบคัดเลือก " + candidate.PeriodExam.Name; + var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่จัดที่นั่งสอบ"; + if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + candidate.Status = "checkSeat"; + var num = periodExam.Count() + 1 + _num; + candidate.ExamIdenNumber = "CDC-" + num; + } + else if (candidate.PeriodExam.Fee != 0) + { + var subject = "แจ้งผลการสมัครสอบคัดเลือก " + candidate.PeriodExam.Name; + var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอชำระค่าสมัครสอบ"; + if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + } + ++_num; + } + + await _context.SaveChangesAsync(); + } public async Task AdminPassCandidateService(string candidateId, string status) {