ตรวจสอบข้อมูลสมัครสอบหลายคน

This commit is contained in:
Kittapath 2023-10-02 11:40:43 +07:00
parent fbef67f33a
commit 974211893a
3 changed files with 91 additions and 2 deletions

View file

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