api ใบสรุปสมัครสอบ

This commit is contained in:
Kittapath 2023-04-06 22:50:53 +07:00
parent ab86c20b84
commit 9f115e3c72
5 changed files with 106 additions and 15 deletions

View file

@ -540,7 +540,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
Consend = candidate != null,
Status = candidate == null ? null : candidate.Status,
PositionExam = position,
PositionExam = candidatePosition?.PositionExam,
Bank = exam.BankExam.Count() > 0,
Position = candidatePosition == null ? false : true
};
@ -1314,6 +1314,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
else if (status == "payment" && candidate.PeriodExam.Fee == 0)
{
candidate.Status = "checkSeat";
var num = periodExam.Count() + 1;
candidate.ExamIdenNumber = "CDC-" + num;
}
if (candidate.Status == "checkSeat")
{
@ -1367,6 +1369,49 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task<RequestCardCandidate> GetsAsyncCardCandidate(string examId, string positionId)
{
var exam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (exam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.Prefix)
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.FirstOrDefaultAsync();
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
candidate = await _context.Candidates.AsQueryable()
.Include(x => x.Prefix)
.Where(x => x.PeriodExam == exam && x.UserId == UserId && x.PositionExam == position)
.FirstOrDefaultAsync();
}
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
return new RequestCardCandidate
{
FirstName = candidate.FirstName,
LastName = candidate.LastName,
Prefix = candidate.Prefix?.Name,
CitizenId = candidate.CitizenId,
ExamIdenNumber = candidate.ExamIdenNumber,
SeatNumber = candidate.SeatNumber,
Point = candidate.Point,
Id = candidate.Id,
};
}
#endregion
}
}

View file

@ -622,10 +622,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
var candidates = new List<Candidate>();
if (periodExam.SetSeat == true)
{
candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "waiver")
.ToListAsync();
}
else
{
candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
}
var stream = new MemoryStream();
using (var package = new ExcelPackage(stream))