เพิ่มฟิว เบอร ให้apiข้อมูลผู้สมัคร
This commit is contained in:
parent
7f792bb8fd
commit
44d18ff74c
4 changed files with 160 additions and 37 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
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;
|
||||||
|
|
@ -32,10 +33,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ข้อมูลรอบการสมัครสอบ
|
/// ข้อมูลรอบการสมัครสอบทั้งหมด
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบสำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบทั้งหมดสำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
@ -56,6 +57,111 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsExamAndCandidateAsync(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _periodExamService.GetsExamAndCandidateAsync(examId, showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">ข้อมูลรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> CreateAsync(PeriodExam item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _periodExamService.CreateAsync(item);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <param name="item">ข้อมูลรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdateAsync(string examId, PeriodExam item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _periodExamService.UpdateAsync(examId, item);
|
||||||
|
|
||||||
|
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>
|
||||||
|
[HttpDelete("{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DeleteAsync(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _periodExamService.DeleteAsync(examId);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
public Models.District? CitizenDistrict { get; set; }
|
public Models.District? CitizenDistrict { get; set; }
|
||||||
public string? CitizenDistrictId { get; set; }
|
public string? CitizenDistrictId { get; set; }
|
||||||
public DateTime? CitizenDate { get; set; }
|
public DateTime? CitizenDate { get; set; }
|
||||||
|
public string? Telephone { get; set; }
|
||||||
|
public string? MobilePhone { get; set; }
|
||||||
|
public string? Knowledge { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
CitizenDate = x.CitizenDate,
|
CitizenDate = x.CitizenDate,
|
||||||
Email = x.Email,
|
Email = x.Email,
|
||||||
CitizenId = x.CitizenId,
|
CitizenId = x.CitizenId,
|
||||||
|
Telephone = x.Telephone,
|
||||||
|
MobilePhone = x.MobilePhone,
|
||||||
|
Knowledge = x.Knowledge,
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -295,6 +298,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.Email = updated.Email;
|
candidate.Email = updated.Email;
|
||||||
candidate.CitizenId = updated.CitizenId;
|
candidate.CitizenId = updated.CitizenId;
|
||||||
candidate.CitizenDate = updated.CitizenDate;
|
candidate.CitizenDate = updated.CitizenDate;
|
||||||
|
candidate.Telephone = updated.Telephone;
|
||||||
|
candidate.MobilePhone = updated.MobilePhone;
|
||||||
|
candidate.Knowledge = updated.Knowledge;
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
@ -48,51 +49,58 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PeriodExam?> GetByIdAsync(Guid id)
|
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string id, bool showAll = true)
|
||||||
{
|
{
|
||||||
return await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == id);
|
return await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == Guid.Parse(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)
|
public async Task CreateAsync(PeriodExam inserted)
|
||||||
{
|
{
|
||||||
inserted.CreatedUserId = UserId ?? "";
|
var periodExam = new PeriodExam
|
||||||
inserted.CreatedFullName = FullName ?? "System Administrator";
|
{
|
||||||
inserted.CreatedAt = DateTime.Now;
|
//xxxxxxxxxxxxxxxxxxxxxxx
|
||||||
inserted.LastUpdatedAt = DateTime.Now;
|
CreatedAt = DateTime.Now,
|
||||||
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
CreatedUserId = UserId ?? "",
|
||||||
inserted.LastUpdateUserId = UserId ?? "";
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
CreatedFullName = FullName ?? "",
|
||||||
|
LastUpdateFullName = FullName ?? "",
|
||||||
|
};
|
||||||
|
|
||||||
await _context.PeriodExams.AddAsync(inserted);
|
await _context.PeriodExams.AddAsync(periodExam);
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(string examId, PeriodExam updated)
|
||||||
|
{
|
||||||
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||||
|
|
||||||
|
if (periodExam == null)
|
||||||
|
throw new Exception(GlobalMessages.ExamNotFound);
|
||||||
|
|
||||||
|
//xxxxxxxxxxxxxxxxxxxxx
|
||||||
|
periodExam.IsActive = updated.IsActive;
|
||||||
|
periodExam.LastUpdatedAt = DateTime.Now;
|
||||||
|
periodExam.LastUpdateUserId = UserId ?? "";
|
||||||
|
periodExam.LastUpdateFullName = FullName ?? "";
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(string examId)
|
||||||
|
{
|
||||||
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||||
|
|
||||||
|
if (periodExam == null)
|
||||||
|
throw new Exception(GlobalMessages.ExamNotFound);
|
||||||
|
|
||||||
|
_context.PeriodExams.Remove(periodExam);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue