api ปฏิเสธจ่ายเงิน get ไฟล์สมัครสอบ
This commit is contained in:
parent
9486ad160d
commit
5abeada4a6
32 changed files with 7513 additions and 394 deletions
|
|
@ -227,6 +227,136 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูล home page cms
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการข้อมูล home page cms สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("home")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<HomePageResponseItem?> GetHomePageAsync()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
var item = await _cmsCandidateService.GetHomePageAsync();
|
||||
|
||||
return item;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูล content home page
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการข้อมูล content home page สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("content/home")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<HomePageContentResponseItem?> GetHomePageContentAsync()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
var item = await _cmsCandidateService.GetHomePageContentAsync();
|
||||
|
||||
return item;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูล content about page
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการข้อมูล content about page สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("content/about")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<AboutPageContentResponseItem?> GetAboutPageContentAsync()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
var item = await _cmsCandidateService.GetAboutPageContentAsync();
|
||||
|
||||
return item;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List ข้อมูลรอบสมัครสอบ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการ List ข้อมูลรอบสมัครสอบ สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("qualifying")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IEnumerable<CMSExamResponseItem?>> GetsCMSExamsAsync(int limit = 0)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
var items = await _cmsCandidateService.GetsCMSExamsAsync(limit);
|
||||
|
||||
return items;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ข้อมูลรอบสมัครสอบ
|
||||
/// </summary>
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการ Get ข้อมูลรอบสมัครสอบ สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("qualifying/{examId:length(36)}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<CMSExamResponseItem?> GetCMSExamsAsync(string examId)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
var item = await _cmsCandidateService.GetCMSExamsAsync(examId);
|
||||
|
||||
return item;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var items = await _candidateService.GetStatusCandidateService(examId, positionId);
|
||||
var item = await _candidateService.GetStatusCandidateService(examId, positionId);
|
||||
|
||||
return Success(GlobalMessages.Success, items);
|
||||
return Success(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -756,19 +756,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var doc = await _candidateService.GetsAsyncProfileImage(examId, positionId);
|
||||
var path = await _candidateService.GetsAsyncProfileImage(examId, positionId);
|
||||
|
||||
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;
|
||||
return Success(GlobalMessages.Success, path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -829,19 +819,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var doc = await _candidateService.GetsAsyncPaymentImg(examId, positionId);
|
||||
var path = await _candidateService.GetsAsyncPaymentImg(examId, positionId);
|
||||
|
||||
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;
|
||||
return Success(GlobalMessages.Success, path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -865,19 +845,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var doc = await _candidateService.GetsAsyncPaymentImgCandidate(candidateId);
|
||||
var path = 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;
|
||||
return Success(GlobalMessages.Success, path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -987,15 +957,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อลบเอกสารหลักฐานสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("upload/{documentId:length(36)}"), DisableRequestSizeLimit]
|
||||
[HttpDelete("upload/{examId:length(36)}/{positionId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string documentId)
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string examId, string positionId, string documentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _candidateService.DeleteAsyncDocument(documentId);
|
||||
await _candidateService.DeleteAsyncDocument(examId, positionId, documentId);
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -1061,7 +1031,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
#region " Fields "
|
||||
|
||||
private readonly PeriodExamService _periodExamService;
|
||||
private readonly MinIOService _minioService;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public PeriodExamController(PeriodExamService periodExamService)
|
||||
public PeriodExamController(PeriodExamService periodExamService, MinIOService minioService)
|
||||
{
|
||||
_periodExamService = periodExamService;
|
||||
_minioService = minioService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -119,7 +121,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost, DisableRequestSizeLimit]
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
|
|
@ -127,15 +129,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||
{
|
||||
return Error(GlobalMessages.NoFileToUpload);
|
||||
}
|
||||
var items = await _periodExamService.CreateAsync(item);
|
||||
|
||||
var files = Request.Form.Files;
|
||||
await _periodExamService.CreateAsync(item, files);
|
||||
|
||||
return Success();
|
||||
return Success(items);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -152,11 +148,38 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[HttpPut("{examId:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateAsync(string examId, RequestPeriodExam item)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _periodExamService.UpdateAsync(examId, item);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทเอกสาร</param>
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{type}/{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDocAsync(string type, string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -166,8 +189,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
|
||||
var files = Request.Form.Files;
|
||||
|
||||
await _periodExamService.UpdateAsync(examId, item, files);
|
||||
if (type == "img")
|
||||
{
|
||||
await _periodExamService.UpdateImgAsync(examId, files);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _periodExamService.UpdateDocAsync(examId, files);
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -463,6 +492,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูล เอกสาร ผู้สมัคร
|
||||
/// </summary>
|
||||
/// <param name="candidate">รหัสผู้สมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการดึง ข้อมูล เอกสาร ผู้สมัคร สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("document/{candidate:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetsAsyncDocument(string candidate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var items = await _periodExamService.GetsAsyncDocument(candidate);
|
||||
|
||||
return Success(items);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อัพเดทข้อมูลที่นั่งสอบ
|
||||
/// </summary>
|
||||
|
|
@ -589,6 +644,31 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบเอกไฟล์
|
||||
/// </summary>
|
||||
/// <param name="documentId">รหัสไฟล์เอกสาร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อลบเอกไฟล์สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("doc/{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string examId, string documentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _periodExamService.DeleteAsyncDocument(examId, documentId);
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@
|
|||
public const string RelationshipNotFound = "ไม่พบข้อมูลสถานะภาพ";
|
||||
public const string ReligionNotFound = "ไม่พบข้อมูลศาสนา";
|
||||
public const string SubDistrictNotFound = "ไม่พบข้อมูลตำบล/แขวง";
|
||||
public const string CMSNotFound = "ไม่พบข้อมูล CMS";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data
|
|||
|
||||
public DbSet<PeriodExamDocument> PeriodExamDocuments { get; set; }
|
||||
|
||||
public DbSet<PeriodExamImage> PeriodExamImages { get; set; }
|
||||
|
||||
public DbSet<CMSCandidate> CMSCandidates { get; set; }
|
||||
|
||||
public DbSet<CMSAgency> CMSAgencys { get; set; }
|
||||
|
|
|
|||
|
|
@ -232,6 +232,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
b.Property<Guid?>("ProvinceId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("ชื่อย่อ");
|
||||
|
||||
b.Property<Guid?>("SubDistrictId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
|
|
@ -1113,6 +1117,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
.HasColumnType("longtext")
|
||||
.HasComment("รายละเอียดสมัครสอบ");
|
||||
|
||||
b.Property<DateTime>("ExamDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่สอบ");
|
||||
|
||||
b.Property<float?>("Fee")
|
||||
.HasColumnType("float")
|
||||
.HasComment("ค่าธรรมเนียม");
|
||||
|
|
@ -1271,6 +1279,68 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
b.ToTable("PeriodExamDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
.HasComment("สร้างข้อมูลเมื่อ");
|
||||
|
||||
b.Property<string>("CreatedFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(104)
|
||||
.HasComment("ชื่อ User ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<string>("CreatedUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<Guid>("DocumentId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(105)
|
||||
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<string>("LastUpdateUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(103)
|
||||
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<DateTime?>("LastUpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<Guid>("PeriodExamId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("PeriodExamId");
|
||||
|
||||
b.ToTable("PeriodExamImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -1926,6 +1996,25 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
b.Navigation("PeriodExam");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamImage", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document")
|
||||
.WithMany()
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
|
||||
.WithMany("PeriodExamImages")
|
||||
.HasForeignKey("PeriodExamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("PeriodExam");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
|
||||
|
|
@ -1966,6 +2055,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
|
||||
b.Navigation("PeriodExamDocuments");
|
||||
|
||||
b.Navigation("PeriodExamImages");
|
||||
|
||||
b.Navigation("PositionExam");
|
||||
});
|
||||
|
||||
|
|
|
|||
2063
Migrations/20230408123727_Add table image exam.Designer.cs
generated
Normal file
2063
Migrations/20230408123727_Add table image exam.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
68
Migrations/20230408123727_Add table image exam.cs
Normal file
68
Migrations/20230408123727_Add table image exam.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Addtableimageexam : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PeriodExamImages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PeriodExamId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PeriodExamImages", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PeriodExamImages_Documents_DocumentId",
|
||||
column: x => x.DocumentId,
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PeriodExamImages_PeriodExams_PeriodExamId",
|
||||
column: x => x.PeriodExamId,
|
||||
principalTable: "PeriodExams",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PeriodExamImages_DocumentId",
|
||||
table: "PeriodExamImages",
|
||||
column: "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PeriodExamImages_PeriodExamId",
|
||||
table: "PeriodExamImages",
|
||||
column: "PeriodExamId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PeriodExamImages");
|
||||
}
|
||||
}
|
||||
}
|
||||
2069
Migrations/20230408125350_update table cms add shortname.Designer.cs
generated
Normal file
2069
Migrations/20230408125350_update table cms add shortname.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
30
Migrations/20230408125350_update table cms add shortname.cs
Normal file
30
Migrations/20230408125350_update table cms add shortname.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetablecmsaddshortname : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ShortName",
|
||||
table: "CMSCandidates",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
comment: "ชื่อย่อ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShortName",
|
||||
table: "CMSCandidates");
|
||||
}
|
||||
}
|
||||
}
|
||||
2073
Migrations/20230408154951_update table exam add examdate.Designer.cs
generated
Normal file
2073
Migrations/20230408154951_update table exam add examdate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
31
Migrations/20230408154951_update table exam add examdate.cs
Normal file
31
Migrations/20230408154951_update table exam add examdate.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetableexamaddexamdate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "ExamDate",
|
||||
table: "PeriodExams",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||
comment: "วันที่สอบ");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ExamDate",
|
||||
table: "PeriodExams");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
|||
[Comment("ชื่อเว็บภาษาไทย")]
|
||||
public string? NameTh { get; set; }
|
||||
|
||||
[Comment("ชื่อย่อ")]
|
||||
public string? ShortName { get; set; }
|
||||
|
||||
[Comment("ชื่อเว็บภาษาอังกฤษ")]
|
||||
public string? NameEn { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
|||
[Required, Column(Order = 6), Comment("วันสิ้นสุดประกาศ")]
|
||||
public DateTime AnnouncementEndDate { get; set; } = DateTime.Now.Date;
|
||||
|
||||
[Required, Comment("วันที่สอบ")]
|
||||
public DateTime ExamDate { get; set; } = DateTime.Now.Date;
|
||||
|
||||
[Comment("Id รหัสส่วนราชการ")]
|
||||
public Guid? OrganizationCodeId { get; set; }
|
||||
|
||||
|
|
@ -80,5 +83,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
|||
|
||||
[Comment("เอกสารอื่นๆ")]
|
||||
public virtual List<PeriodExamDocument> PeriodExamDocuments { get; set; } = new();
|
||||
|
||||
[Comment("รูป")]
|
||||
public virtual List<PeriodExamImage> PeriodExamImages { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
Models/PeriodExamImage.cs
Normal file
15
Models/PeriodExamImage.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models.Documents;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||
{
|
||||
public class PeriodExamImage : EntityBase
|
||||
{
|
||||
[Required, Comment("Id รอบสมัครสอบ")]
|
||||
public virtual PeriodExam? PeriodExam { get; set; }
|
||||
[Required, Comment("Id ไฟล์รูป")]
|
||||
public virtual Document? Document { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public string? ProfileImg { get; set; }
|
||||
// public Models.Document? ProfileImgId { get; set; }
|
||||
public string? NameTh { get; set; }
|
||||
public string? ShortName { get; set; }
|
||||
public string? NameEn { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? About { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public class RequestCMSDetail
|
||||
{
|
||||
public string? NameTh { get; set; }
|
||||
public string? ShortName { get; set; }
|
||||
public string? NameEn { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public DateTime PaymentEndDate { get; set; } = DateTime.Now.Date;
|
||||
public DateTime AnnouncementStartDate { get; set; } = DateTime.Now.Date;
|
||||
public DateTime AnnouncementEndDate { get; set; } = DateTime.Now.Date;
|
||||
public DateTime ExamDate { get; set; } = DateTime.Now.Date;
|
||||
public Guid? OrganizationCodeId { get; set; }
|
||||
public string? OrganizationCodeName { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
|
|
@ -23,6 +24,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public string? PaymentKrungThai { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public List<FormFile>? Doc { get; set; }
|
||||
public List<FormFile>? Image { get; set; }
|
||||
public List<RequestBankExam> BankExam { get; set; } = new();
|
||||
public List<RequestPositionExam> PositionExam { get; set; } = new();
|
||||
}
|
||||
|
|
|
|||
10
Response/AboutPageContentResponseItem.cs
Normal file
10
Response/AboutPageContentResponseItem.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class AboutPageContentResponseItem
|
||||
{
|
||||
public string? Content { get; set; }
|
||||
}
|
||||
}
|
||||
22
Response/CMSExamResponseItem.cs
Normal file
22
Response/CMSExamResponseItem.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class CMSExamResponseItem
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Category { get; set; }
|
||||
public string? Category_id { get; set; }
|
||||
public DateTime? Start { get; set; }
|
||||
public DateTime? End { get; set; }
|
||||
public DateTime? Exam_date { get; set; }
|
||||
public DateTime? Announcement_date { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public string? Image { get; set; }
|
||||
public List<HomePageLinkResponseItem>? Images { get; set; }
|
||||
public List<HomePageLinkResponseItem>? Files { get; set; }
|
||||
public List<HomePageLinkResponseItem>? Positions { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -21,5 +21,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
|||
public string? Telephone { get; set; }
|
||||
public string? MobilePhone { get; set; }
|
||||
public string? Knowledge { get; set; }
|
||||
public string? ProfileImg { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
Response/CandidateStatusResponse.cs
Normal file
11
Response/CandidateStatusResponse.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Net;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class CandidateStatusResponse
|
||||
{
|
||||
public string? Status { get; set; }
|
||||
|
||||
public string? RejectDetail { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -9,5 +9,7 @@
|
|||
public string? FileType { get; set; } = string.Empty;
|
||||
|
||||
public int? FileSize { get; set; }
|
||||
|
||||
public string? Detail { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
Response/HomePageContentResponseItem.cs
Normal file
11
Response/HomePageContentResponseItem.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class HomePageContentResponseItem
|
||||
{
|
||||
public string? Content { get; set; }
|
||||
public string? Image { get; set; }
|
||||
}
|
||||
}
|
||||
22
Response/HomePageResponseItem.cs
Normal file
22
Response/HomePageResponseItem.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class HomePageResponseItem
|
||||
{
|
||||
public string? Logo_url { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Subtitle { get; set; }
|
||||
public string? Supervised { get; set; }
|
||||
public string? Telephone { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public List<HomePageLinkResponseItem>? Divisions { get; set; }
|
||||
public List<HomePageLinkResponseItem>? Institutes { get; set; }
|
||||
}
|
||||
public class HomePageLinkResponseItem
|
||||
{
|
||||
public string? Title { get; set; }
|
||||
public string? Url { get; set; }
|
||||
}
|
||||
}
|
||||
11
Response/PaymentImgResponse.cs
Normal file
11
Response/PaymentImgResponse.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Net;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class PaymentImgResponse
|
||||
{
|
||||
public string? PaymentImg { get; set; }
|
||||
|
||||
public string? RejectDetail { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
|||
public DateTime PaymentEndDate { get; set; }
|
||||
public DateTime AnnouncementStartDate { get; set; }
|
||||
public DateTime AnnouncementEndDate { get; set; }
|
||||
public DateTime ExamDate { get; set; }
|
||||
public Guid? OrganizationCodeId { get; set; }
|
||||
public string? OrganizationCodeName { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
|
|
@ -31,5 +32,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
|||
public List<Models.PositionExam> PositionExam { get; set; } = new List<Models.PositionExam>();
|
||||
public List<Models.BankExam> BankExam { get; set; } = new List<Models.BankExam>();
|
||||
public List<FileListResponse> Documents { get; set; } = new List<FileListResponse>();
|
||||
public List<FileListResponse> Images { get; set; } = new List<FileListResponse>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
public async Task<CMSCandidate> GetsAsync()
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
if (cms.LogoImg != null)
|
||||
cms.LogoImg.Detail = _minioService.ImagesPath(cms.LogoImg.Id).Result;
|
||||
|
||||
if (cms.BannerImg != null)
|
||||
cms.BannerImg.Detail = _minioService.ImagesPath(cms.BannerImg.Id).Result;
|
||||
|
||||
return cms;
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +89,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
var cms = await createCMS();
|
||||
|
||||
cms.NameTh = updated.NameTh;
|
||||
cms.ShortName = updated.ShortName;
|
||||
cms.NameEn = updated.NameEn;
|
||||
cms.Description = updated.Description;
|
||||
cms.LastUpdatedAt = DateTime.Now;
|
||||
|
|
@ -129,9 +137,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
cms.ZipCode = subDistrict.ZipCode;
|
||||
}
|
||||
|
||||
cms.NameTh = updated.About;
|
||||
cms.NameEn = updated.Address;
|
||||
cms.Description = updated.Telephone;
|
||||
cms.About = updated.About;
|
||||
cms.Address = updated.Address;
|
||||
cms.Telephone = updated.Telephone;
|
||||
cms.LastUpdatedAt = DateTime.Now;
|
||||
cms.LastUpdateUserId = UserId ?? "";
|
||||
cms.LastUpdateFullName = FullName ?? "";
|
||||
|
|
@ -231,6 +239,168 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<HomePageResponseItem> GetHomePageAsync()
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
|
||||
.Select(x => new HomePageResponseItem
|
||||
{
|
||||
Logo_url = x.LogoImg == null ? "" : x.LogoImg.Id.ToString(),
|
||||
Title = x.NameTh,
|
||||
Subtitle = x.NameEn,
|
||||
Supervised = x.ShortName,
|
||||
Telephone = x.Telephone,
|
||||
Address = x.Address + " " + (x.SubDistrict == null ? "" : "แขวง" + x.SubDistrict.Name + " ") + (x.District == null ? "" : "เขต" + x.District.Name) + " " + (x.Province == null ? "" : x.Province.Name) + " " + (x.SubDistrict == null ? "" : x.SubDistrict.ZipCode),
|
||||
Divisions = x.CMSAgencys.Select(s => new HomePageLinkResponseItem
|
||||
{
|
||||
Title = s.Name,
|
||||
Url = s.Link,
|
||||
}).ToList(),
|
||||
Institutes = x.CMSGovernments.Select(s => new HomePageLinkResponseItem
|
||||
{
|
||||
Title = s.Name,
|
||||
Url = s.Link,
|
||||
}).ToList(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (cmsCandidates == null)
|
||||
throw new Exception(GlobalMessages.CMSNotFound);
|
||||
|
||||
if (cmsCandidates.Logo_url != null && cmsCandidates.Logo_url != "")
|
||||
cmsCandidates.Logo_url = _minioService.ImagesPath(Guid.Parse(cmsCandidates.Logo_url)).Result;
|
||||
|
||||
return cmsCandidates;
|
||||
}
|
||||
|
||||
public async Task<HomePageContentResponseItem> GetHomePageContentAsync()
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
|
||||
.Select(x => new HomePageContentResponseItem
|
||||
{
|
||||
Content = x.Description,
|
||||
Image = x.BannerImg == null ? "" : x.BannerImg.Id.ToString(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (cmsCandidates == null)
|
||||
throw new Exception(GlobalMessages.CMSNotFound);
|
||||
|
||||
if (cmsCandidates.Image != null && cmsCandidates.Image != "")
|
||||
cmsCandidates.Image = _minioService.ImagesPath(Guid.Parse(cmsCandidates.Image)).Result;
|
||||
|
||||
return cmsCandidates;
|
||||
}
|
||||
|
||||
public async Task<AboutPageContentResponseItem> GetAboutPageContentAsync()
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
|
||||
.Select(x => new AboutPageContentResponseItem
|
||||
{
|
||||
Content = x.About,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (cmsCandidates == null)
|
||||
throw new Exception(GlobalMessages.CMSNotFound);
|
||||
|
||||
return cmsCandidates;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CMSExamResponseItem?>> GetsCMSExamsAsync(int limit)
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
var periodExams = await _context.PeriodExams.AsQueryable()
|
||||
.Where(x => x.AnnouncementStartDate <= DateTime.Now)
|
||||
.Where(x => x.AnnouncementEndDate >= DateTime.Now)
|
||||
.Include(x => x.PeriodExamImages)
|
||||
.Select(x => new CMSExamResponseItem
|
||||
{
|
||||
Id = x.Id.ToString(),
|
||||
Category = "doctor",
|
||||
Category_id = "doctor",
|
||||
Start = x.ExamDate,
|
||||
End = x.ExamDate,
|
||||
Exam_date = x.ExamDate,
|
||||
Announcement_date = x.AnnouncementStartDate,
|
||||
Title = x.Name,
|
||||
Image = x.PeriodExamImages.OrderBy(o => o.CreatedAt).FirstOrDefault() == null ?
|
||||
"" :
|
||||
x.PeriodExamImages.OrderBy(o => o.CreatedAt).FirstOrDefault().Document.Id.ToString(),
|
||||
})
|
||||
.ToListAsync();
|
||||
if (limit > 0)
|
||||
periodExams = periodExams.Take(limit).ToList();
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in periodExams)
|
||||
{
|
||||
if (periodExams[i].Image != null && periodExams[i].Image != "")
|
||||
periodExams[i].Image = _minioService.ImagesPath(Guid.Parse(periodExams[i].Image)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return periodExams;
|
||||
}
|
||||
|
||||
public async Task<CMSExamResponseItem> GetCMSExamsAsync(string examId)
|
||||
{
|
||||
var cms = await createCMS();
|
||||
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Where(x => x.Id == Guid.Parse(examId))
|
||||
.Include(x => x.PeriodExamImages)
|
||||
.Select(x => new CMSExamResponseItem
|
||||
{
|
||||
Id = x.Id.ToString(),
|
||||
Category = "doctor",
|
||||
Category_id = "doctor",
|
||||
Start = x.ExamDate,
|
||||
Title = x.Name,
|
||||
Detail = x.Detail,
|
||||
Images = x.PeriodExamImages.Select(s => new HomePageLinkResponseItem
|
||||
{
|
||||
Title = s.Document.FileName,
|
||||
Url = s.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
Files = x.PeriodExamDocuments.Select(s => new HomePageLinkResponseItem
|
||||
{
|
||||
Title = s.Document.FileName,
|
||||
Url = s.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
Positions = x.PositionExam.Select(s => new HomePageLinkResponseItem
|
||||
{
|
||||
Title = s.Id.ToString(),
|
||||
Url = $"{x.Id}/{s.Id}",
|
||||
}).ToList(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in periodExam.Images)
|
||||
{
|
||||
if (periodExam.Images[i].Url != null && periodExam.Images[i].Url != "")
|
||||
periodExam.Images[i].Url = _minioService.ImagesPath(Guid.Parse(periodExam.Images[i].Url)).Result;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach (var item in periodExam.Files)
|
||||
{
|
||||
if (periodExam.Files[i].Url != null && periodExam.Files[i].Url != "")
|
||||
periodExam.Files[i].Url = _minioService.ImagesPath(Guid.Parse(periodExam.Files[i].Url)).Result;
|
||||
i++;
|
||||
}
|
||||
return periodExam;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return await _context.CandidateDocuments.AsQueryable()
|
||||
var document = await _context.CandidateDocuments.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.Select(x => new FileListResponse
|
||||
{
|
||||
|
|
@ -422,8 +422,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
FileName = x.Document == null ? "" : x.Document.FileName,
|
||||
FileType = x.Document == null ? "" : x.Document.FileType,
|
||||
FileSize = x.Document == null ? 0 : x.Document.FileSize,
|
||||
Detail = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in document)
|
||||
{
|
||||
if (document[i].Detail != null && document[i].Detail != "")
|
||||
document[i].Detail = _minioService.ImagesPath(Guid.Parse(document[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public async Task<string> GetsAsyncProfileImage(string examId, string positionId)
|
||||
|
|
@ -456,10 +467,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate.ProfileImg == null ? "" : candidate.ProfileImg.Id.ToString();
|
||||
if (candidate.ProfileImg != null)
|
||||
candidate.ProfileImg.Detail = _minioService.ImagesPath(candidate.ProfileImg.Id).Result;
|
||||
|
||||
return candidate.ProfileImg == null ? "" : candidate.ProfileImg.Detail;
|
||||
}
|
||||
|
||||
public async Task<string> GetsAsyncPaymentImg(string examId, string positionId)
|
||||
public async Task<PaymentImgResponse> GetsAsyncPaymentImg(string examId, string positionId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
|
@ -489,7 +503,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString();
|
||||
if (candidate.PaymentImg != null)
|
||||
candidate.PaymentImg.Detail = _minioService.ImagesPath(candidate.PaymentImg.Id).Result;
|
||||
|
||||
return new PaymentImgResponse { PaymentImg = candidate.PaymentImg == null ? "" : candidate.PaymentImg.Detail, RejectDetail = candidate.RejectDetail };
|
||||
}
|
||||
|
||||
public async Task<string> GetsAsyncPaymentImgCandidate(string candidateId)
|
||||
|
|
@ -502,7 +519,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Id.ToString();
|
||||
if (candidate.PaymentImg != null)
|
||||
candidate.PaymentImg.Detail = _minioService.ImagesPath(candidate.PaymentImg.Id).Result;
|
||||
|
||||
return candidate.PaymentImg == null ? "" : candidate.PaymentImg.Detail.ToString();
|
||||
}
|
||||
|
||||
public async Task<RequestStatusRegistry> GetsAsyncRegisterExam(string examId, string positionId)
|
||||
|
|
@ -873,7 +893,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
if (candidate.ProfileImg != null)
|
||||
{
|
||||
await DeleteAsyncDocument(candidate.ProfileImg.Id.ToString());
|
||||
await DeleteDocument(candidate.ProfileImg.Id.ToString());
|
||||
}
|
||||
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
|
@ -1078,11 +1098,28 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string documentId)
|
||||
public async Task DeleteDocument(string documentId)
|
||||
{
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string examId, string positionId, string documentId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var position = exam.PositionExam.Where(x => x.Id == Guid.Parse(positionId)).FirstOrDefault();
|
||||
|
||||
if (position == null)
|
||||
throw new Exception(GlobalMessages.PositionExamNotFound);
|
||||
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task CreateAsyncCareer(string examId, string positionId, CandidateCareerResponseItem updated)
|
||||
{
|
||||
var candidateId = await CreateAsyncCandidate(examId, positionId);
|
||||
|
|
@ -1219,7 +1256,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<string> GetStatusCandidateService(string examId, string positionId)
|
||||
public async Task<CandidateStatusResponse> GetStatusCandidateService(string examId, string positionId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
|
@ -1245,7 +1282,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
return candidate.Status;
|
||||
return new CandidateStatusResponse { Status = candidate.Status, RejectDetail = candidate.RejectDetail };
|
||||
}
|
||||
|
||||
public async Task UserCheckCandidateService(string examId, string positionId, string status)
|
||||
|
|
@ -1358,7 +1395,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
if (candidate.PaymentImg != null)
|
||||
{
|
||||
await DeleteAsyncDocument(candidate.PaymentImg.Id.ToString());
|
||||
await DeleteDocument(candidate.PaymentImg.Id.ToString());
|
||||
}
|
||||
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
this._bucketName = _configuration["MinIO:BucketName"] ?? "bma-recruit";
|
||||
}
|
||||
|
||||
public static IConfigurationRoot Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
|
@ -185,6 +196,34 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<string> ImagesPath(Guid fileId)
|
||||
{
|
||||
if (fileId == null)
|
||||
return "";
|
||||
|
||||
var doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == fileId);
|
||||
|
||||
if (doc == null)
|
||||
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||
var config = new AmazonS3Config
|
||||
{
|
||||
ServiceURL = Configuration.GetValue<string>("MinIO:Endpoint"),
|
||||
ForcePathStyle = true
|
||||
};
|
||||
|
||||
DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||
{
|
||||
BucketName = _bucketName,
|
||||
Key = doc?.ObjectRefId.ToString("D"),
|
||||
Expires = expires,
|
||||
};
|
||||
string path = _s3Client.GetPreSignedURL(request);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +49,46 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
return await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
ExamDate = x.ExamDate,
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
CheckDocument = x.CheckDocument,
|
||||
Detail = x.Detail,
|
||||
Fee = x.Fee,
|
||||
Id = x.Id,
|
||||
IsActive = x.IsActive,
|
||||
Name = x.Name,
|
||||
Note = x.Note,
|
||||
OrganizationCodeId = x.OrganizationCodeId,
|
||||
OrganizationCodeName = x.OrganizationCodeName,
|
||||
OrganizationId = x.OrganizationId,
|
||||
OrganizationName = x.OrganizationName,
|
||||
PaymentEndDate = x.PaymentEndDate,
|
||||
PaymentKrungThai = x.PaymentKrungThai,
|
||||
PaymentStartDate = x.PaymentStartDate,
|
||||
RegisterEndDate = x.RegisterEndDate,
|
||||
RegisterStartDate = x.RegisterStartDate,
|
||||
Round = x.Round,
|
||||
SetSeat = x.SetSeat,
|
||||
Year = x.Year,
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExamCandidateResponseItem?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.Include(x => x.PeriodExamDocuments)
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
ExamDate = x.ExamDate,
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
|
|
@ -98,19 +132,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
Images = x.PeriodExamImages.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in periodExam.Images)
|
||||
{
|
||||
if (periodExam.Images[i].Detail != null && periodExam.Images[i].Detail != "")
|
||||
periodExam.Images[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.Images[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach (var item in periodExam.Documents)
|
||||
{
|
||||
if (periodExam.Documents[i].Detail != null && periodExam.Documents[i].Detail != "")
|
||||
periodExam.Documents[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.Documents[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return periodExam;
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +209,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(RequestPeriodExam inserted, IFormFileCollection files)
|
||||
public async Task<Guid> CreateAsync(RequestPeriodExam inserted)
|
||||
{
|
||||
var periodExam = new PeriodExam
|
||||
{
|
||||
|
|
@ -172,6 +224,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
PaymentStartDate = inserted.PaymentStartDate,
|
||||
PaymentEndDate = inserted.PaymentEndDate,
|
||||
AnnouncementStartDate = inserted.AnnouncementStartDate,
|
||||
ExamDate = inserted.ExamDate,
|
||||
AnnouncementEndDate = inserted.AnnouncementEndDate,
|
||||
OrganizationCodeId = inserted.OrganizationCodeId,
|
||||
OrganizationCodeName = inserted.OrganizationCodeName,
|
||||
|
|
@ -225,35 +278,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.PositionExams.AddAsync(positionExam);
|
||||
}
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
if (document == null)
|
||||
throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
|
||||
var periodExamDocument = new PeriodExamDocument
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.PeriodExamDocuments.AddAsync(periodExamDocument);
|
||||
}
|
||||
|
||||
await _context.PeriodExams.AddAsync(periodExam);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return periodExam.Id;
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated, IFormFileCollection files)
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.BankExam)
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.Candidate)
|
||||
.Include(x => x.PeriodExamDocuments)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
|
@ -272,6 +308,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
periodExam.PaymentStartDate = updated.PaymentStartDate;
|
||||
periodExam.PaymentEndDate = updated.PaymentEndDate;
|
||||
periodExam.AnnouncementStartDate = updated.AnnouncementStartDate;
|
||||
periodExam.ExamDate = updated.ExamDate;
|
||||
periodExam.AnnouncementEndDate = updated.AnnouncementEndDate;
|
||||
periodExam.OrganizationCodeId = updated.OrganizationCodeId;
|
||||
periodExam.OrganizationCodeName = updated.OrganizationCodeName;
|
||||
|
|
@ -284,20 +321,54 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
periodExam.LastUpdateUserId = UserId ?? "";
|
||||
periodExam.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
if (updated.PaymentKrungThai != "payment2")
|
||||
{
|
||||
var bankData = updated.BankExam
|
||||
.FirstOrDefault(x => x.Id == bank.Id);
|
||||
if (bankData != null)
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
{
|
||||
bank.AccountName = bankData.AccountName;
|
||||
bank.AccountNumber = bankData.AccountNumber;
|
||||
bank.BankName = bankData.BankName;
|
||||
bank.LastUpdatedAt = DateTime.Now;
|
||||
bank.LastUpdateUserId = UserId ?? "";
|
||||
bank.LastUpdateFullName = FullName ?? "";
|
||||
var bankData = updated.BankExam
|
||||
.FirstOrDefault(x => x.Id == bank.Id);
|
||||
if (bankData != null)
|
||||
{
|
||||
bank.AccountName = bankData.AccountName;
|
||||
bank.AccountNumber = bankData.AccountNumber;
|
||||
bank.BankName = bankData.BankName;
|
||||
bank.LastUpdatedAt = DateTime.Now;
|
||||
bank.LastUpdateUserId = UserId ?? "";
|
||||
bank.LastUpdateFullName = FullName ?? "";
|
||||
}
|
||||
else
|
||||
{
|
||||
var bankDelete = await _context.BankExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == bank.Id);
|
||||
|
||||
if (bankDelete != null)
|
||||
_context.BankExams.Remove(bankDelete);
|
||||
}
|
||||
}
|
||||
else
|
||||
var bankAdd = updated.BankExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
foreach (var bank in bankAdd)
|
||||
{
|
||||
var bankExam = new BankExam
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
AccountName = bank.AccountName,
|
||||
AccountNumber = bank.AccountNumber,
|
||||
BankName = bank.BankName,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
await _context.BankExams.AddAsync(bankExam);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
{
|
||||
var bankDelete = await _context.BankExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == bank.Id);
|
||||
|
|
@ -327,31 +398,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.FirstOrDefaultAsync(x => x.Id == position.Id);
|
||||
|
||||
if (positionDelete != null)
|
||||
{
|
||||
if (periodExam.Candidate.Count() > 0)
|
||||
throw new Exception("รอบนี้มีการสมัครแล้วไม่สามารถลบตำแหน่งได้");
|
||||
_context.PositionExams.Remove(positionDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var bankAdd = updated.BankExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
foreach (var bank in bankAdd)
|
||||
{
|
||||
var bankExam = new BankExam
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
AccountName = bank.AccountName,
|
||||
AccountNumber = bank.AccountNumber,
|
||||
BankName = bank.BankName,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
await _context.BankExams.AddAsync(bankExam);
|
||||
}
|
||||
|
||||
var positionAdd = updated.PositionExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
|
|
@ -374,13 +428,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.PositionExams.AddAsync(positionExam);
|
||||
}
|
||||
|
||||
foreach (var doc in periodExam.PeriodExamDocuments)
|
||||
{
|
||||
if (doc.Id != null)
|
||||
{
|
||||
await DeleteAsyncDocument(doc.Id.ToString());
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateDocAsync(string examId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
|
@ -404,8 +461,50 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string documentId)
|
||||
public async Task UpdateImgAsync(string examId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
if (document == null)
|
||||
throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
|
||||
var periodExamImage = new PeriodExamImage
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.PeriodExamImages.AddAsync(periodExamImage);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteDocument(string documentId)
|
||||
{
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string examId, string documentId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +544,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
public async Task<CandidateInformationResponseItem?> GetsAsyncInformation(string candidateId)
|
||||
{
|
||||
return await _context.Candidates.AsQueryable()
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.Id == Guid.Parse(candidateId))
|
||||
.Select(x => new CandidateInformationResponseItem
|
||||
{
|
||||
|
|
@ -467,8 +566,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
Telephone = x.Telephone,
|
||||
MobilePhone = x.MobilePhone,
|
||||
Knowledge = x.Knowledge,
|
||||
ProfileImg = x.ProfileImg == null ? "" : x.ProfileImg.Id.ToString(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (candidate == null)
|
||||
return candidate;
|
||||
|
||||
if (candidate.ProfileImg != null && candidate.ProfileImg != "")
|
||||
candidate.ProfileImg = _minioService.ImagesPath(Guid.Parse(candidate.ProfileImg)).Result;
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
public async Task<CandidateOccupationResponseItem?> GetsAsyncOccupation(string candidateId)
|
||||
|
|
@ -560,6 +668,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileListResponse?>> GetsAsyncDocument(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
var document = await _context.CandidateDocuments.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.Select(x => new FileListResponse
|
||||
{
|
||||
Id = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
FileName = x.Document == null ? "" : x.Document.FileName,
|
||||
FileType = x.Document == null ? "" : x.Document.FileType,
|
||||
FileSize = x.Document == null ? 0 : x.Document.FileSize,
|
||||
Detail = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in document)
|
||||
{
|
||||
if (document[i].Detail != null && document[i].Detail != "")
|
||||
document[i].Detail = _minioService.ImagesPath(Guid.Parse(document[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
private async Task<List<RequestImportSeat>> ReadExcelCandidate(IFormFile formFile)
|
||||
{
|
||||
var list = new List<RequestImportSeat>();
|
||||
|
|
@ -726,16 +865,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
return stream;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<BankExam?>> GetsPaymentExamAsync(string examId)
|
||||
public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.BankExam)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
.Where(x => x.Id == Guid.Parse(examId))
|
||||
.Select(x => new PeriodExam
|
||||
{
|
||||
BankExam = x.BankExam,
|
||||
Fee = x.Fee,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return periodExam.BankExam;
|
||||
return periodExam;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue