From 5d8a0b842aa587c4f8dd5273b356026959a392ff Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 14 Nov 2024 19:53:41 +0700 Subject: [PATCH] fix : Leave user commander and organization name fix: handle lastSalary amount while null value --- .../Profiles/GetProfileByKeycloakIdDto.cs | 2 ++ .../Controllers/LeaveRequestController.cs | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs index 16f80b70..6c0fb20c 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs @@ -54,6 +54,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? Child4 { get; set; } + public string? Commander { get; set; } + } public class PosLevel diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 3eab8066..cb0d3e2d 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -694,13 +694,14 @@ namespace BMA.EHR.Leave.Service.Controllers var lastSalary = profile.ProfileSalary; var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + var approver = profile.Commander ?? ""; + var userOc = profile.Root ?? ""; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type); @@ -714,7 +715,7 @@ namespace BMA.EHR.Leave.Service.Controllers Dear = approver, PositionName = profile.Position == null ? "" : profile.Position, PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName, - OrganizationName = profile.Oc ?? "", + OrganizationName = userOc, //profile.Oc ?? "", LeaveLimit = leaveType.Limit, LeaveTotal = sumLeave, @@ -722,8 +723,8 @@ namespace BMA.EHR.Leave.Service.Controllers RestDayTotalOld = restOldDay, BirthDate = profile.BirthDate.Date, DateAppoint = profile.DateAppoint == null ? null : profile.DateAppoint.Value.Date, - Salary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value, - SalaryText = lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), + Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value, + SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), LeaveLast = leaveLast == null ? null : leaveLast };