From 93a83b34e6e0bab690af4270b06cd2a2b9f88c87 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 19 Jan 2026 17:15:17 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B9=81=E0=B8=9A=E0=B8=9A=E0=B9=83=E0=B8=9A=E0=B8=82=E0=B8=AD?= =?UTF-8?q?=E0=B8=A2=E0=B8=81=E0=B9=80=E0=B8=A5=E0=B8=B4=E0=B8=81=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/LeaveReportController.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 0dec80c6..5dad15fa 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -1136,9 +1136,28 @@ namespace BMA.EHR.Leave.Service.Controllers dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), @@ -2834,7 +2853,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? x.LastUpdatedAt.Value.Date.ToThaiShortDate().ToThaiNumber() : "............/............/............", comment = !string.IsNullOrEmpty(x.Comment) - ? x.Comment.Replace("\r", "").Replace("\n", " ").Trim() + ? (x.Comment.Replace("\r", "").Replace("\n", " ").Trim()).ToThaiNumber() : "......................................................................................................................................................................", approveType = (x.ApproveType ?? "").Trim().ToUpper() }) From 1aab307f6a2545ecd21671cb6440b52a3d618ecd Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 19 Jan 2026 18:17:11 +0700 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B9=83=E0=B8=AB=E0=B9=89=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B9=83?= =?UTF-8?q?=E0=B8=8A=E0=B9=89=E0=B8=AA=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4?= =?UTF-8?q?=E0=B9=8C=20API=20=E0=B9=80=E0=B8=AA=E0=B9=89=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B5=E0=B8=A2=E0=B8=A7=E0=B8=81=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B8=87=E0=B8=82=E0=B8=A3=E0=B8=81.=20#2173?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RetirementOutController.cs | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index e996abab..be31a5c9 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -239,16 +239,6 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpGet("{id:length(36)}")] public async Task> GetDetailAdmin(Guid id) { - var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), "SYS_DISMISS"); - if (getWorkflow == false) - { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISMISS"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") - { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); - } - } var data = await _context.RetirementOuts.AsQueryable() .Where(x => x.Id == id) .Select(p => new @@ -294,6 +284,20 @@ namespace BMA.EHR.Retirement.Service.Controllers p.OrganizationOld, }) .FirstOrDefaultAsync(); + + string _system = data != null && data.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), _system); + if (getWorkflow == false) + { + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISMISS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + } + if (data == null) return Error(GlobalMessages.DataNotFound, 404); @@ -462,14 +466,18 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpPut("{id:length(36)}")] public async Task> Put([FromBody] RetirementOutEditRequest req, Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_DISMISS"); + var uppdated = await _context.RetirementOuts + .FirstOrDefaultAsync(x => x.Id == id); + + string _system = uppdated != null && uppdated.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", _system); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var uppdated = await _context.RetirementOuts - .FirstOrDefaultAsync(x => x.Id == id); + if (uppdated == null) return Error(GlobalMessages.RetirementOutNotFound, 404); @@ -527,14 +535,18 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpDelete("{id:length(36)}")] public async Task> Delete(Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_DISMISS"); + var deleted = await _context.RetirementOuts.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == id); + + string _system = deleted != null && deleted.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getPermission = await _permission.GetPermissionAPIAsync("DELETE", _system); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var deleted = await _context.RetirementOuts.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == id); + if (deleted == null) return NotFound(); _context.RetirementOuts.Remove(deleted);