get รูปถ่ายสมัครสอบ

This commit is contained in:
Kittapath 2023-04-03 10:43:43 +07:00
parent 5b1f9cc72b
commit 62cd728ff5
2 changed files with 88 additions and 0 deletions

View file

@ -777,6 +777,58 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// get id รูปถ่าย
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อ get id รูปถ่ายสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("profile-img/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncProfileImage(string examId)
{
try
{
var doc = await _candidateService.GetsAsyncProfileImage(examId);
return Success(doc);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// get id หลักฐานชำระ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อ get id หลักฐานชำระสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("payment-img/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncPaymentImg(string examId)
{
try
{
var doc = await _candidateService.GetsAsyncPaymentImg(examId);
return Success(doc);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// อัปโหลดเอกสารหลักฐาน
/// </summary>

View file

@ -249,6 +249,42 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.ToListAsync(); ;
}
public async Task<string> GetsAsyncProfileImage(string examId)
{
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()
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.FirstOrDefaultAsync();
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
return candidate.ProfileImg == null ? "" : candidate.ProfileImg.Id.ToString();
}
public async Task<string> GetsAsyncPaymentImg(string examId)
{
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()
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.FirstOrDefaultAsync();
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString();
}
public async Task<bool> GetsAsyncRegisterExam(string examId)
{
var exam = await _context.PeriodExams.AsQueryable()