ตรวจสอบข้อมูลสมัครสอบหลายคน
This commit is contained in:
parent
fbef67f33a
commit
974211893a
3 changed files with 91 additions and 2 deletions
|
|
@ -717,6 +717,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครหลายคน
|
||||
/// </summary>
|
||||
/// <param name="candidateId">รหัสใบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("check-registers")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครไม่ผ่านและให้สมัครใหม่
|
||||
/// </summary>
|
||||
|
|
|
|||
9
Request/RequestApproves.cs
Normal file
9
Request/RequestApproves.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System.Net;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Request
|
||||
{
|
||||
public class RequestApproves
|
||||
{
|
||||
public string[]? CandidateId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue