diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs
index 23c1ff6..6b50211 100644
--- a/Controllers/CandidateController.cs
+++ b/Controllers/CandidateController.cs
@@ -917,6 +917,38 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
+ ///
+ /// อัปเอกสารหลักฐานการชำระเงิน
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่ออัปเอกสารหลักฐานสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("upload-payment/{examId:length(36)}"), DisableRequestSizeLimit]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> UploadPaymentCandidateService(string examId)
+ {
+ try
+ {
+ if (Request.Form.Files == null || Request.Form.Files.Count == 0)
+ {
+ return Error(GlobalMessages.NoFileToUpload);
+ }
+
+ var file = Request.Form.Files[0];
+ await _candidateService.UpdateAsyncPaymentImage(examId, file);
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
#endregion
}
}
diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs
index 79ab2a7..94d9810 100644
--- a/Services/CandidateService.cs
+++ b/Services/CandidateService.cs
@@ -1003,6 +1003,25 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
+ public async Task UpdateAsyncPaymentImage(string examId, IFormFile file)
+ {
+ var candidateId = await CreateAsyncCandidate(examId);
+
+ var candidate = await _context.Candidates.AsQueryable()
+ .FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
+
+ if (candidate == null)
+ throw new Exception(GlobalMessages.ExamNotFound);
+
+ var doc = await _minioService.UploadFileAsync(file);
+
+ var document = await _context.Documents.AsQueryable()
+ .FirstOrDefaultAsync(x => x.Id == doc.Id);
+
+ candidate.PaymentImg = document;
+ await _context.SaveChangesAsync();
+ }
+
#endregion
}
}