แสดงรูปหลักฐานชำระ

This commit is contained in:
Kittapath 2023-04-06 15:42:43 +07:00
parent 43898213b2
commit ab86c20b84
6 changed files with 75 additions and 8 deletions

View file

@ -849,6 +849,42 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
} }
} }
/// <summary>
/// get id หลักฐานชำระ
/// </summary>
/// <param name="candidateId">รหัสผู้สมัครสอบ</param>
/// <returns></returns>
/// <response code="200">เมื่อ get id หลักฐานชำระสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("payment-image/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncPaymentImgCandidate(string candidateId)
{
try
{
var doc = await _candidateService.GetsAsyncPaymentImgCandidate(candidateId);
if (doc == "")
return Success();
var file_data = await _minioService.DownloadFileAsync(Guid.Parse(doc));
Response.Headers["Content-Disposition"] = $"inline; filename={file_data.FileName}";
var ret = new FileContentResult(file_data.FileContent, file_data.FileType)
{
FileDownloadName = file_data.FileName
};
return ret;
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary> /// <summary>
/// อัปเอกสารหลักฐานการชำระเงิน /// อัปเอกสารหลักฐานการชำระเงิน
/// </summary> /// </summary>

View file

@ -475,6 +475,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
{ {
return Error("นามสกุลไฟล์ต้องเป็น .xlsx!"); return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
} }
// return Success(file);
await _periodExamService.UploadSeatCandidateAsync(examId, file); await _periodExamService.UploadSeatCandidateAsync(examId, file);
return Success(); return Success();
@ -510,6 +511,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
{ {
return Error("นามสกุลไฟล์ต้องเป็น .xlsx!"); return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
} }
// return Success(file);
await _periodExamService.UploadPointCandidateAsync(examId, file); await _periodExamService.UploadPointCandidateAsync(examId, file);
return Success(); return Success();

View file

@ -7,6 +7,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
{ {
public bool Consend { get; set; } public bool Consend { get; set; }
public bool Position { get; set; } public bool Position { get; set; }
public bool Bank { get; set; }
public string? Status { get; set; } public string? Status { get; set; }
public PositionExam? PositionExam { get; set; } public PositionExam? PositionExam { get; set; }
} }

10
Request/testtest.cs Normal file
View file

@ -0,0 +1,10 @@
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

@ -492,9 +492,23 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString(); return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString();
} }
public async Task<string> GetsAsyncPaymentImgCandidate(string candidateId)
{
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.PaymentImg)
.Where(x => x.Id == Guid.Parse(candidateId))
.FirstOrDefaultAsync();
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString();
}
public async Task<RequestStatusRegistry> GetsAsyncRegisterExam(string examId, string positionId) public async Task<RequestStatusRegistry> GetsAsyncRegisterExam(string examId, string positionId)
{ {
var exam = await _context.PeriodExams.AsQueryable() var exam = await _context.PeriodExams.AsQueryable()
.Include(x => x.BankExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId)); .FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (exam == null) if (exam == null)
@ -503,10 +517,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var candidate = await _context.Candidates.AsQueryable() var candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId); .FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (positionId != "00000000-0000-0000-0000-000000000000") if (positionId != "00000000-0000-0000-0000-000000000000")
{ {
var position = await _context.PositionExams.AsQueryable() // var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam); // .FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null) if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound); throw new Exception(GlobalMessages.PositionExamNotFound);
@ -523,7 +540,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{ {
Consend = candidate != null, Consend = candidate != null,
Status = candidate == null ? null : candidate.Status, Status = candidate == null ? null : candidate.Status,
PositionExam = candidatePosition?.PositionExam, PositionExam = position,
Bank = exam.BankExam.Count() > 0,
Position = candidatePosition == null ? false : true Position = candidatePosition == null ? false : true
}; };
} }
@ -1279,9 +1297,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate.PeriodExam == null) if (candidate.PeriodExam == null)
throw new Exception(GlobalMessages.ExamNotFound); throw new Exception(GlobalMessages.ExamNotFound);
var periodExam = await _context.PeriodExams.AsQueryable() var periodExam = await _context.Candidates.AsQueryable()
.Include(x => x.Candidate) .Where(x => x.PeriodExam == candidate.PeriodExam && x.ExamIdenNumber != null)
.FirstOrDefaultAsync(x => x.Id == candidate.PeriodExam.Id); .ToListAsync();
if (periodExam == null) if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound); throw new Exception(GlobalMessages.ExamNotFound);
@ -1299,7 +1317,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
} }
if (candidate.Status == "checkSeat") if (candidate.Status == "checkSeat")
{ {
var num = periodExam.Candidate.Count() + 1; var num = periodExam.Count() + 1;
candidate.ExamIdenNumber = "CDC-" + num; candidate.ExamIdenNumber = "CDC-" + num;
} }
} }

View file

@ -595,7 +595,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (item != null) if (item != null)
{ {
if (candidate.Status == "checkPoint") if (candidate.Status == "checkPoint" || candidate.Status == "done")
{ {
candidate.Point = item.Point; candidate.Point = item.Point;
candidate.Status = "done"; candidate.Status = "done";