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)
{