diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
index a485a42d..1a9260ef 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
@@ -62,9 +62,9 @@ namespace BMA.EHR.Placement.Service.Controllers
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
-
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
+ private bool isSuperAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("SUPER_ADMIN") ?? false;
#endregion
@@ -852,6 +852,39 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
+ ///
+ /// API อัพเดทสถานะเป็นบรรจุ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("pass/update-status")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> PersonUpdateStatus([FromBody] PersonUpdateStatusRequest req)
+ {
+ if (isSuperAdmin == false)
+ return Success();
+
+ var person = await _context.PlacementProfiles
+ .FirstOrDefaultAsync(x => x.Id == req.PersonalId);
+ if (person == null)
+ return Error(GlobalMessages.DataNotFound, 404);
+
+ person.PlacementStatus = "DONE";
+ person.LastUpdateFullName = FullName ?? "System Administrator";
+ person.LastUpdateUserId = UserId ?? "";
+ person.LastUpdatedAt = DateTime.Now;
+
+ await _context.SaveChangesAsync();
+
+ return Success();
+ }
+
[HttpGet("pass/deferment/{personalId:length(36)}")]
public async Task> GetPersonDeferment(Guid personalId)
{
diff --git a/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs
new file mode 100644
index 00000000..aef70fb5
--- /dev/null
+++ b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs
@@ -0,0 +1,10 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Placement.Service.Requests
+{
+ public class PersonUpdateStatusRequest
+ {
+ public Guid PersonalId { get; set; }
+ }
+}