diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index dd90ae6..fc1ba9f 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -2025,6 +2025,21 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (status == "checkRegister") { + // เช็คเลขบัตรซ้ำ + var candidate2 = await _context.Candidates.AsQueryable() + .Where(x => + x.PeriodExam == exam + && x.UserId != UserId + && x.CitizenId == candidate.CitizenId + && ( + (exam.Fee > 0 && x.Status.Trim().ToUpper() != "REGISTER") + || (exam.Fee == 0 && x.Status.Trim().ToUpper() == "CHECKSEAT") + ) + ) + .FirstOrDefaultAsync(); + if (candidate2 != null) + throw new Exception(GlobalMessages.CitizanDupicate); + var subject = "แจ้งผลการสมัครสอบคัดเลือก " + exam.Name; var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ได้รับใบสมัครแล้ว"; if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);