ปรับระบบสรรหาสอบคัดเลือก (4)

This commit is contained in:
harid 2025-11-19 10:31:20 +07:00
parent efb22a9d73
commit fe4781030b
4 changed files with 30 additions and 29 deletions

View file

@ -830,13 +830,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> CheckShowExamInfoService(RequestApproves item)
public async Task<ActionResult<ResponseObject>> CheckShowExamInfoService(RequestApproveShowExamInfo item)
{
try
{
if (item.CandidateId != null)
if (!string.IsNullOrEmpty(item.ExamId))
{
await _candidateService.AdminCheckShowExamInfoService(item.CandidateId);
await _candidateService.AdminCheckShowExamInfoService(item.ExamId);
}
return Success();

View file

@ -0,0 +1,9 @@
using System.Net;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestApproveShowExamInfo
{
public string? ExamId { get; set; }
}
}

View file

@ -5,14 +5,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
{
// public Models.Prefix? Prefix { get; set; }
public string? PrefixId { get; set; }
public string? PrefixName { get; set; }
public string? PrefixName { get; set; } = string.Empty;
public string? FirstName { get; set; } = string.Empty;
public string? LastName { get; set; } = string.Empty;
public string? Nationality { get; set; } = string.Empty;
public DateTime? DateOfBirth { get; set; }
// public Models.Relationship? Relationship { get; set; }
public string? ReligionId { get; set; }
public string? ReligionName { get; set; }
public string? ReligionName { get; set; } = string.Empty;
public string? Email { get; set; } = string.Empty;
public string? CitizenId { get; set; } = string.Empty;
// public Models.Province? CitizenProvince { get; set; }
@ -88,7 +88,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public Guid? EducationLevelHighId { get; set; }
public Guid? ContactPrefixId { get; set; }
public string? ContactPrefixName { get; set; }
public string? ContactPrefixName { get; set; } = string.Empty;
public string? ContactFirstname { get; set; }
public string? ContactLastname { get; set; }
public string? ContactRelations { get; set; }

View file

@ -7,6 +7,7 @@ using BMA.EHR.Recurit.Exam.Service.Request;
using BMA.EHR.Recurit.Exam.Service.Response;
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace BMA.EHR.Recurit.Exam.Service.Services
{
@ -2271,34 +2272,25 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task AdminCheckShowExamInfoService(string[] candidateId)
public async Task AdminCheckShowExamInfoService(string examId)
{
foreach (var _candidateId in candidateId)
{
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.Include(x => x.PositionExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(_candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
if (candidate.Status.Trim().ToUpper() != "CHECKSEAT")
continue;
if (candidate.PeriodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var periodExam = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == candidate.PeriodExam)
.Where(x => x.PositionExam == candidate.PositionExam)
.Where(x => x.ExamIdenNumber != null)
.Where(x => x.Status != "register")
.OrderByDescending(d => d.CreatedAt)
.ToListAsync();
var examGuid = Guid.Parse(examId);
var periodExam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == examGuid);
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.Where(x => x.PeriodExam.Id == examGuid && x.IsShowExamInfo == false)
.ToListAsync();
foreach (var candidate in candidates)
{
if (candidate.Status.Trim().ToUpper() != "CHECKSEAT")
continue;
candidate.IsShowExamInfo = true;
}