diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs
index 4f6c51b..b486b06 100644
--- a/Controllers/CandidateController.cs
+++ b/Controllers/CandidateController.cs
@@ -638,31 +638,31 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
- ///
- /// ผู้สมัครทำการบันทึกหลักฐานชำระเงิน
- ///
- /// รหัสรอบสมัคร
- ///
- /// เมื่อทำการผู้สมัครทำการบันทึกหลักฐานชำระเงิน สำเร็จ
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("payment/{examId:length(36)}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task> PaymentedCandidateService(string examId)
- {
- try
- {
- await _candidateService.UserCheckCandidateService(examId, "checkPayment");
+ // ///
+ // /// ผู้สมัครทำการบันทึกหลักฐานชำระเงิน
+ // ///
+ // /// รหัสรอบสมัคร
+ // ///
+ // /// เมื่อทำการผู้สมัครทำการบันทึกหลักฐานชำระเงิน สำเร็จ
+ // /// ไม่ได้ Login เข้าระบบ
+ // /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ // [HttpGet("payment/{examId:length(36)}")]
+ // [ProducesResponseType(StatusCodes.Status200OK)]
+ // [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ // [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ // public async Task> PaymentedCandidateService(string examId)
+ // {
+ // try
+ // {
+ // await _candidateService.UserCheckCandidateService(examId, "checkPayment");
- return Success();
- }
- catch (Exception ex)
- {
- return Error(ex);
- }
- }
+ // return Success();
+ // }
+ // catch (Exception ex)
+ // {
+ // return Error(ex);
+ // }
+ // }
///
/// เจ้าหน้าที่ตรวจการชำระเงิน
@@ -716,6 +716,42 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
+ ///
+ /// get id รูปถ่าย
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่อ get id รูปถ่ายสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("profile-image/{examId:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetsAsyncProfileImage(string examId)
+ {
+ try
+ {
+ var doc = await _candidateService.GetsAsyncProfileImage(examId);
+
+ 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);
+ }
+ }
+
///
/// อัปโหลดรูปถ่ายผู้สมัคร
///
@@ -751,6 +787,75 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
+ ///
+ /// get id หลักฐานชำระ
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่อ get id หลักฐานชำระสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("payment-image/{examId:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetsAsyncPaymentImg(string examId)
+ {
+ try
+ {
+ var doc = await _candidateService.GetsAsyncPaymentImg(examId);
+
+ 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);
+ }
+ }
+
+ ///
+ /// อัปเอกสารหลักฐานการชำระเงิน
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่ออัปเอกสารหลักฐานสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("payment-image/{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);
+ await _candidateService.UserCheckCandidateService(examId, "checkPayment");
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
///
/// list เอกสารหลักฐาน
///
@@ -777,72 +882,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
- ///
- /// get id รูปถ่าย
- ///
- /// รหัสรอบสมัคร
- ///
- /// เมื่อ get id รูปถ่ายสำเร็จ
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("profile-img/{examId:length(36)}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task> GetsAsyncProfileImage(string examId)
- {
- try
- {
- var doc = await _candidateService.GetsAsyncProfileImage(examId);
-
- var file_data = await _minioService.DownloadFileAsync(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);
- }
- }
-
- ///
- /// get id หลักฐานชำระ
- ///
- /// รหัสรอบสมัคร
- ///
- /// เมื่อ get id หลักฐานชำระสำเร็จ
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("payment-img/{examId:length(36)}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task> GetsAsyncPaymentImg(string examId)
- {
- try
- {
- var doc = await _candidateService.GetsAsyncPaymentImg(examId);
-
- var file_data = await _minioService.DownloadFileAsync(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);
- }
- }
-
///
/// อัปโหลดเอกสารหลักฐาน
///
@@ -931,38 +970,6 @@ 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 3b1b568..25a5323 100644
--- a/Services/CandidateService.cs
+++ b/Services/CandidateService.cs
@@ -258,7 +258,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
throw new Exception(GlobalMessages.ExamNotFound);
var candidate = await _context.Candidates.AsQueryable()
- .Include(x=>x.ProfileImg)
+ .Include(x => x.ProfileImg)
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.FirstOrDefaultAsync();
@@ -277,7 +277,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
throw new Exception(GlobalMessages.ExamNotFound);
var candidate = await _context.Candidates.AsQueryable()
- .Include(x=>x.PaymentImg)
+ .Include(x => x.PaymentImg)
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.FirstOrDefaultAsync();
@@ -594,11 +594,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var candidateId = await CreateAsyncCandidate(examId);
var candidate = await _context.Candidates.AsQueryable()
+ .Include(x => x.ProfileImg)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.ExamNotFound);
+ if (candidate.ProfileImg != null)
+ {
+ await DeleteAsyncDocument(candidate.ProfileImg.Id.ToString());
+ }
+
var doc = await _minioService.UploadFileAsync(file);
var document = await _context.Documents.AsQueryable()
@@ -1010,11 +1016,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var candidateId = await CreateAsyncCandidate(examId);
var candidate = await _context.Candidates.AsQueryable()
+ .Include(x => x.PaymentImg)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.ExamNotFound);
+ if (candidate.PaymentImg != null)
+ {
+ await DeleteAsyncDocument(candidate.PaymentImg.Id.ToString());
+ }
+
var doc = await _minioService.UploadFileAsync(file);
var document = await _context.Documents.AsQueryable()
diff --git a/appsettings.Development.json b/appsettings.Development.json
index 7155c95..479fcb9 100644
--- a/appsettings.Development.json
+++ b/appsettings.Development.json
@@ -26,9 +26,9 @@
}
},
"MinIO": {
- "Endpoint": "http://127.0.0.1:9000",
- "AccessKey": "lLXkeFav7rtu3GlP",
- "SecretKey": "K8KxwNyqedWy7p2HPsTJRoMOlnoXgDa1",
+ "Endpoint": "https://s3.frappet.com/",
+ "AccessKey": "frappet",
+ "SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
}
}
diff --git a/appsettings.json b/appsettings.json
index 3f6949c..5ab9afd 100644
--- a/appsettings.json
+++ b/appsettings.json
@@ -26,9 +26,9 @@
}
},
"MinIO": {
- "Endpoint": "http://127.0.0.1:9000",
- "AccessKey": "lLXkeFav7rtu3GlP",
- "SecretKey": "K8KxwNyqedWy7p2HPsTJRoMOlnoXgDa1",
+ "Endpoint": "https://s3.frappet.com/",
+ "AccessKey": "frappet",
+ "SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
}
}
\ No newline at end of file
diff --git a/bin/Debug/net7.0/appsettings.Development.json b/bin/Debug/net7.0/appsettings.Development.json
index 7155c95..479fcb9 100644
--- a/bin/Debug/net7.0/appsettings.Development.json
+++ b/bin/Debug/net7.0/appsettings.Development.json
@@ -26,9 +26,9 @@
}
},
"MinIO": {
- "Endpoint": "http://127.0.0.1:9000",
- "AccessKey": "lLXkeFav7rtu3GlP",
- "SecretKey": "K8KxwNyqedWy7p2HPsTJRoMOlnoXgDa1",
+ "Endpoint": "https://s3.frappet.com/",
+ "AccessKey": "frappet",
+ "SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
}
}
diff --git a/bin/Debug/net7.0/appsettings.json b/bin/Debug/net7.0/appsettings.json
index 3f6949c..5ab9afd 100644
--- a/bin/Debug/net7.0/appsettings.json
+++ b/bin/Debug/net7.0/appsettings.json
@@ -26,9 +26,9 @@
}
},
"MinIO": {
- "Endpoint": "http://127.0.0.1:9000",
- "AccessKey": "lLXkeFav7rtu3GlP",
- "SecretKey": "K8KxwNyqedWy7p2HPsTJRoMOlnoXgDa1",
+ "Endpoint": "https://s3.frappet.com/",
+ "AccessKey": "frappet",
+ "SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
}
}
\ No newline at end of file