เพิ่มวัหมดอายุเลขบัตร
This commit is contained in:
parent
a781c375d7
commit
7018791857
9 changed files with 638 additions and 285 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
using BMA.EHR.Recurit.Exam.Service.Request;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Services;
|
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -31,10 +32,36 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
|
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ข้อมูล สถานะ ผู้สมัครสอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการดึง ข้อมูล สถานะ ผู้สมัคร สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("status/{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetStatusCandidateService(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _candidateService.GetStatusCandidateService(examId);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร
|
/// ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -60,7 +87,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร
|
/// ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -86,7 +113,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล ข้อมูลครอบครัว ผู้สมัคร
|
/// ข้อมูล ข้อมูลครอบครัว ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลครอบครัว ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล ข้อมูลครอบครัว ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -112,7 +139,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล อาชีพ ผู้สมัคร
|
/// ข้อมูล อาชีพ ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล อาชีพ ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล อาชีพ ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -138,7 +165,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร
|
/// ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -164,7 +191,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูล ประวัติการศีกษา ผู้สมัคร
|
/// ข้อมูล ประวัติการศีกษา ผู้สมัคร
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการดึง ข้อมูล ประวัติการศีกษา ผู้สมัคร สำเร็จ</response>
|
/// <response code="200">เมื่อทำการดึง ข้อมูล ประวัติการศีกษา ผู้สมัคร สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -190,7 +217,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ตรวจสอบว่าผู้ใช้งานสมัครสอบหรือยัง
|
/// ตรวจสอบว่าผู้ใช้งานสมัครสอบหรือยัง
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการตรวจสอบว่าผู้ใช้งานสมัครสอบหรือยัง สำเร็จ</response>
|
/// <response code="200">เมื่อทำการตรวจสอบว่าผู้ใช้งานสมัครสอบหรือยัง สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -426,7 +453,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ผู้สมัครทำการสมัครสอบ
|
/// ผู้สมัครทำการสมัครสอบ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสการสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการผู้สมัครทำการสมัครสอบ สำเร็จ</response>
|
/// <response code="200">เมื่อทำการผู้สมัครทำการสมัครสอบ สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -439,7 +466,111 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _candidateService.RegisterCandidateService(examId);
|
await _candidateService.UserCheckCandidateService(examId, "checkRegister");
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เจ้าหน้าที่ตรวจคุณสมบัติผู้สมัคร
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">รหัสใบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("check-register/{candidate:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> CheckRegisterCandidateService(string candidate, RequestApprove item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _candidateService.AdminCheckCandidateService(candidate, item.Status ? "payment" : "rejectRegister");
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ผู้สมัครทำการบันทึกหลักฐานชำระเงิน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการผู้สมัครทำการบันทึกหลักฐานชำระเงิน สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("payment/{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PaymentedCandidateService(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _candidateService.UserCheckCandidateService(examId, "checkPayment");
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เจ้าหน้าที่ตรวจการชำระเงิน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">รหัสใบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจการชำระเงินสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("pass-register/{candidate:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> CheckPaymentCandidateService(string candidate, RequestApprove item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _candidateService.AdminCheckCandidateService(candidate, item.Status ? "pending" : "rejectPayment");
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เจ้าหน้าที่บันทึกสถานที่สอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">รหัสใบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อเจ้าหน้าที่บันทึกสถานที่สอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("pass-register/{candidate:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> CheckDoneCandidateService(string candidate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _candidateService.AdminCheckCandidateService(candidate, "done");
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
61
Controllers/PeriodExamController.cs
Normal file
61
Controllers/PeriodExamController.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/period-exam")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลคำนำหน้า เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PeriodExamController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PeriodExamService _periodExamService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PeriodExamController(PeriodExamService periodExamService)
|
||||||
|
{
|
||||||
|
_periodExamService = periodExamService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะ ข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _periodExamService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
public string UserId { get; set; } = string.Empty;
|
public string UserId { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required, MaxLength(20), Comment("สถานะผู้สมัคร")]
|
[Required, MaxLength(20), Comment("สถานะผู้สมัคร")]
|
||||||
public string status { get; set; } = "draft";
|
public string status { get; set; } = "register";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ builder.Services.AddTransient<ProvinceService>();
|
||||||
builder.Services.AddTransient<DistrictService>();
|
builder.Services.AddTransient<DistrictService>();
|
||||||
builder.Services.AddTransient<SubDistrictService>();
|
builder.Services.AddTransient<SubDistrictService>();
|
||||||
builder.Services.AddTransient<CandidateService>();
|
builder.Services.AddTransient<CandidateService>();
|
||||||
|
builder.Services.AddTransient<PeriodExamService>();
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllers(options =>
|
builder.Services.AddControllers(options =>
|
||||||
|
|
|
||||||
10
Request/RequestApprove.cs
Normal file
10
Request/RequestApprove.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Request
|
||||||
|
{
|
||||||
|
public class RequestApprove
|
||||||
|
{
|
||||||
|
public bool Status { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,5 +13,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
public string? RelationshipId { get; set; }
|
public string? RelationshipId { get; set; }
|
||||||
public string? Email { get; set; } = string.Empty;
|
public string? Email { get; set; } = string.Empty;
|
||||||
public string? CitizenId { get; set; } = string.Empty;
|
public string? CitizenId { get; set; } = string.Empty;
|
||||||
|
public Models.Province? CitizenProvince { get; set; }
|
||||||
|
public string? CitizenProvinceId { get; set; }
|
||||||
|
public Models.District? CitizenDistrict { get; set; }
|
||||||
|
public string? CitizenDistrictId { get; set; }
|
||||||
|
public DateTime? CitizenDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
.Select(x => new CandidateInformationResponseItem
|
.Select(x => new CandidateInformationResponseItem
|
||||||
{
|
{
|
||||||
Prefix = x.Prefix,
|
Prefix = x.Prefix,
|
||||||
|
PrefixId = x.Prefix != null ? x.Prefix.Id.ToString() : null,
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
Nationality = x.Nationality,
|
Nationality = x.Nationality,
|
||||||
DateOfBirth = x.DateOfBirth,
|
DateOfBirth = x.DateOfBirth,
|
||||||
Relationship = x.Relationship,
|
Relationship = x.Relationship,
|
||||||
|
RelationshipId = x.Relationship != null ? x.Relationship.Id.ToString() : null,
|
||||||
|
CitizenProvince = x.CitizenProvince,
|
||||||
|
CitizenProvinceId = x.CitizenProvince != null ? x.CitizenProvince.Id.ToString() : null,
|
||||||
|
CitizenDistrict = x.CitizenDistrict,
|
||||||
|
CitizenDistrictId = x.CitizenDistrict != null ? x.CitizenDistrict.Id.ToString() : null,
|
||||||
|
CitizenDate = x.CitizenDate,
|
||||||
Email = x.Email,
|
Email = x.Email,
|
||||||
CitizenId = x.CitizenId,
|
CitizenId = x.CitizenId,
|
||||||
})
|
})
|
||||||
|
|
@ -75,14 +82,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
{
|
{
|
||||||
RegistAddress = x.RegistAddress,
|
RegistAddress = x.RegistAddress,
|
||||||
RegistProvince = x.RegistProvince,
|
RegistProvince = x.RegistProvince,
|
||||||
|
RegistProvinceId = x.RegistProvince != null ? x.RegistProvince.Id.ToString() : null,
|
||||||
RegistDistrict = x.RegistDistrict,
|
RegistDistrict = x.RegistDistrict,
|
||||||
|
RegistDistrictId = x.RegistDistrict != null ? x.RegistDistrict.Id.ToString() : null,
|
||||||
RegistSubDistrict = x.RegistSubDistrict,
|
RegistSubDistrict = x.RegistSubDistrict,
|
||||||
|
RegistSubDistrictId = x.RegistSubDistrict != null ? x.RegistSubDistrict.Id.ToString() : null,
|
||||||
RegistZipCode = x.RegistZipCode,
|
RegistZipCode = x.RegistZipCode,
|
||||||
RegistSame = x.RegistSame,
|
RegistSame = x.RegistSame,
|
||||||
CurrentAddress = x.CurrentAddress,
|
CurrentAddress = x.CurrentAddress,
|
||||||
CurrentProvince = x.CurrentProvince,
|
CurrentProvince = x.CurrentProvince,
|
||||||
|
CurrentProvinceId = x.CurrentProvince != null ? x.CurrentProvince.Id.ToString() : null,
|
||||||
CurrentDistrict = x.CurrentDistrict,
|
CurrentDistrict = x.CurrentDistrict,
|
||||||
|
CurrentDistrictId = x.CurrentDistrict != null ? x.CurrentDistrict.Id.ToString() : null,
|
||||||
CurrentSubDistrict = x.CurrentSubDistrict,
|
CurrentSubDistrict = x.CurrentSubDistrict,
|
||||||
|
CurrentSubDistrictId = x.CurrentSubDistrict != null ? x.CurrentSubDistrict.Id.ToString() : null,
|
||||||
CurrentZipCode = x.CurrentZipCode,
|
CurrentZipCode = x.CurrentZipCode,
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -102,12 +115,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
{
|
{
|
||||||
Marry = x.Marry,
|
Marry = x.Marry,
|
||||||
MarryPrefix = x.MarryPrefix,
|
MarryPrefix = x.MarryPrefix,
|
||||||
|
MarryPrefixId = x.MarryPrefix != null ? x.MarryPrefix.Id.ToString() : null,
|
||||||
MarryFirstName = x.MarryFirstName,
|
MarryFirstName = x.MarryFirstName,
|
||||||
MarryLastName = x.MarryLastName,
|
MarryLastName = x.MarryLastName,
|
||||||
FatherPrefix = x.FatherPrefix,
|
FatherPrefix = x.FatherPrefix,
|
||||||
|
FatherPrefixId = x.FatherPrefix != null ? x.FatherPrefix.Id.ToString() : null,
|
||||||
FatherFirstName = x.FatherFirstName,
|
FatherFirstName = x.FatherFirstName,
|
||||||
FatherLastName = x.FatherLastName,
|
FatherLastName = x.FatherLastName,
|
||||||
MotherPrefix = x.MotherPrefix,
|
MotherPrefix = x.MotherPrefix,
|
||||||
|
MotherPrefixId = x.MotherPrefix != null ? x.MotherPrefix.Id.ToString() : null,
|
||||||
MotherFirstName = x.MotherFirstName,
|
MotherFirstName = x.MotherFirstName,
|
||||||
MotherLastName = x.MotherLastName,
|
MotherLastName = x.MotherLastName,
|
||||||
})
|
})
|
||||||
|
|
@ -252,12 +268,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.Relationship = relationship;
|
candidate.Relationship = relationship;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updated.CitizenProvinceId != null)
|
||||||
|
{
|
||||||
|
var citizenProvince = await _context.Provinces.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenProvinceId));
|
||||||
|
|
||||||
|
if (citizenProvince == null)
|
||||||
|
throw new Exception(GlobalMessages.ProvinceNotFound);
|
||||||
|
candidate.CitizenProvince = citizenProvince;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updated.CitizenDistrictId != null)
|
||||||
|
{
|
||||||
|
var citizenDistrict = await _context.Districts.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CitizenDistrictId));
|
||||||
|
|
||||||
|
if (citizenDistrict == null)
|
||||||
|
throw new Exception(GlobalMessages.DistrictNotFound);
|
||||||
|
candidate.CitizenDistrict = citizenDistrict;
|
||||||
|
}
|
||||||
|
|
||||||
candidate.FirstName = updated.FirstName;
|
candidate.FirstName = updated.FirstName;
|
||||||
candidate.LastName = updated.LastName;
|
candidate.LastName = updated.LastName;
|
||||||
candidate.Nationality = updated.Nationality;
|
candidate.Nationality = updated.Nationality;
|
||||||
candidate.DateOfBirth = updated.DateOfBirth;
|
candidate.DateOfBirth = updated.DateOfBirth;
|
||||||
candidate.Email = updated.Email;
|
candidate.Email = updated.Email;
|
||||||
candidate.CitizenId = updated.CitizenId;
|
candidate.CitizenId = updated.CitizenId;
|
||||||
|
candidate.CitizenDate = updated.CitizenDate;
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -282,16 +319,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.RegistProvince = registProvince;
|
candidate.RegistProvince = registProvince;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated.RegistProvinceId != null)
|
|
||||||
{
|
|
||||||
var registProvince = await _context.Provinces.AsQueryable()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.RegistProvinceId));
|
|
||||||
|
|
||||||
if (registProvince == null)
|
|
||||||
throw new Exception(GlobalMessages.ProvinceNotFound);
|
|
||||||
candidate.RegistProvince = registProvince;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updated.RegistDistrictId != null)
|
if (updated.RegistDistrictId != null)
|
||||||
{
|
{
|
||||||
var registDistrict = await _context.Districts.AsQueryable()
|
var registDistrict = await _context.Districts.AsQueryable()
|
||||||
|
|
@ -323,16 +350,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.CurrentProvince = currentProvince;
|
candidate.CurrentProvince = currentProvince;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated.CurrentProvinceId != null)
|
|
||||||
{
|
|
||||||
var currentProvince = await _context.Provinces.AsQueryable()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(updated.CurrentProvinceId));
|
|
||||||
|
|
||||||
if (currentProvince == null)
|
|
||||||
throw new Exception(GlobalMessages.ProvinceNotFound);
|
|
||||||
candidate.CurrentProvince = currentProvince;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updated.CurrentDistrictId != null)
|
if (updated.CurrentDistrictId != null)
|
||||||
{
|
{
|
||||||
var currentDistrict = await _context.Districts.AsQueryable()
|
var currentDistrict = await _context.Districts.AsQueryable()
|
||||||
|
|
@ -543,7 +560,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RegisterCandidateService(string examId)
|
public async Task<string> GetStatusCandidateService(string examId)
|
||||||
{
|
{
|
||||||
var exam = await _context.PeriodExams.AsQueryable()
|
var exam = await _context.PeriodExams.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||||
|
|
@ -557,7 +574,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate == null)
|
if (candidate == null)
|
||||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||||
|
|
||||||
candidate.status = "registered";
|
return candidate.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UserCheckCandidateService(string examId, string status)
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
|
||||||
|
|
||||||
|
if (candidate == null)
|
||||||
|
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||||
|
|
||||||
|
candidate.status = status;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AdminCheckCandidateService(string candidateId, string status)
|
||||||
|
{
|
||||||
|
var candidate = await _context.Candidates.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||||
|
|
||||||
|
if (candidate == null)
|
||||||
|
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||||
|
|
||||||
|
candidate.status = status;
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
98
Services/PeriodExamService.cs
Normal file
98
Services/PeriodExamService.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
|
{
|
||||||
|
public class PeriodExamService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PeriodExamService(ApplicationDbContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PeriodExam>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PeriodExams.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PeriodExams.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PeriodExam?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PeriodExam updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PeriodExam inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PeriodExams.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue