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

@ -1035,6 +1035,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// ใบสมัครสอบ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <param name="positionId">Id ตำแหน่งสมัครสอบ</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการใบสมัครสอบ สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("card/{examId:length(36)}/{positionId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncCardCandidate(string examId, string positionId)
{
try
{
var items = await _candidateService.GetsAsyncCardCandidate(examId, positionId);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
#endregion
}
}

View file

@ -0,0 +1,17 @@
using System.Net;
using BMA.EHR.Recurit.Exam.Service.Models;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestCardCandidate
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? Prefix { get; set; }
public string? CitizenId { get; set; }
public string? ExamIdenNumber { get; set; }
public string? SeatNumber { get; set; }
public string? Point { get; set; }
public Guid? Id { get; set; }
}
}

View file

@ -1,10 +0,0 @@
using System.Net;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class testtest
{
public CancellationToken? xxx { get; set; }
public MemoryStream? zzz { get; set; }
}
}

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