diff --git a/Controllers/PeriodExamController.cs b/Controllers/PeriodExamController.cs
index 80a010b..a79c54c 100644
--- a/Controllers/PeriodExamController.cs
+++ b/Controllers/PeriodExamController.cs
@@ -1,3 +1,4 @@
+using BMA.EHR.Recurit.Exam.Service.Models;
using BMA.EHR.Recurit.Exam.Service.Response;
using BMA.EHR.Recurit.Exam.Service.Services;
using Microsoft.AspNetCore.Authorization;
@@ -32,10 +33,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
#region " Methods "
///
- /// ข้อมูลรอบการสมัครสอบ
+ /// ข้อมูลรอบการสมัครสอบทั้งหมด
///
///
- /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบสำเร็จ
+ /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบทั้งหมดสำเร็จ
/// ไม่ได้ Login เข้าระบบ
/// เมื่อเกิดข้อผิดพลาดในการทำงาน
[HttpGet]
@@ -56,6 +57,111 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
+ ///
+ /// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("{examId:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetsExamAndCandidateAsync(string examId)
+ {
+ try
+ {
+ var items = await _periodExamService.GetsExamAndCandidateAsync(examId, showAll: false);
+
+ return Success(items);
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
+ ///
+ /// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
+ ///
+ /// ข้อมูลรอบสมัคร
+ ///
+ /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> CreateAsync(PeriodExam item)
+ {
+ try
+ {
+ await _periodExamService.CreateAsync(item);
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
+ ///
+ /// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
+ ///
+ /// รหัสรอบสมัคร
+ /// ข้อมูลรอบสมัคร
+ ///
+ /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("{examId:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> UpdateAsync(string examId, PeriodExam item)
+ {
+ try
+ {
+ await _periodExamService.UpdateAsync(examId, item);
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
+ ///
+ /// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
+ ///
+ /// รหัสรอบสมัคร
+ ///
+ /// เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpDelete("{examId:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> DeleteAsync(string examId)
+ {
+ try
+ {
+ await _periodExamService.DeleteAsync(examId);
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
#endregion
}
}
diff --git a/Response/CandidateInformationResponseItem.cs b/Response/CandidateInformationResponseItem.cs
index b1f0bcb..61ed50e 100644
--- a/Response/CandidateInformationResponseItem.cs
+++ b/Response/CandidateInformationResponseItem.cs
@@ -18,5 +18,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public Models.District? CitizenDistrict { get; set; }
public string? CitizenDistrictId { get; set; }
public DateTime? CitizenDate { get; set; }
+ public string? Telephone { get; set; }
+ public string? MobilePhone { get; set; }
+ public string? Knowledge { get; set; }
}
}
diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs
index ce5a8e4..ef7a6cf 100644
--- a/Services/CandidateService.cs
+++ b/Services/CandidateService.cs
@@ -64,6 +64,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
CitizenDate = x.CitizenDate,
Email = x.Email,
CitizenId = x.CitizenId,
+ Telephone = x.Telephone,
+ MobilePhone = x.MobilePhone,
+ Knowledge = x.Knowledge,
})
.FirstOrDefaultAsync();
}
@@ -295,6 +298,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.Email = updated.Email;
candidate.CitizenId = updated.CitizenId;
candidate.CitizenDate = updated.CitizenDate;
+ candidate.Telephone = updated.Telephone;
+ candidate.MobilePhone = updated.MobilePhone;
+ candidate.Knowledge = updated.Knowledge;
await _context.SaveChangesAsync();
}
diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs
index a6909ad..20f04d2 100644
--- a/Services/PeriodExamService.cs
+++ b/Services/PeriodExamService.cs
@@ -1,4 +1,5 @@
using System.Security.Claims;
+using BMA.EHR.Recurit.Exam.Service.Core;
using BMA.EHR.Recurit.Exam.Service.Data;
using BMA.EHR.Recurit.Exam.Service.Models;
using Microsoft.EntityFrameworkCore;
@@ -48,51 +49,58 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.ToListAsync();
}
- public async Task GetByIdAsync(Guid id)
+ public async Task GetsExamAndCandidateAsync(string id, bool showAll = true)
{
- 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();
- }
+ return await _context.PeriodExams.FirstOrDefaultAsync(x => x.Id == Guid.Parse(id));
}
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 ?? "";
+ var periodExam = new PeriodExam
+ {
+ //xxxxxxxxxxxxxxxxxxxxxxx
+ CreatedAt = DateTime.Now,
+ CreatedUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ LastUpdateUserId = UserId ?? "",
+ CreatedFullName = FullName ?? "",
+ LastUpdateFullName = FullName ?? "",
+ };
- await _context.PeriodExams.AddAsync(inserted);
+ await _context.PeriodExams.AddAsync(periodExam);
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
}
}