From 62f2fd85cc62394baa352f073aa41f8923f16c70 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 14 Nov 2024 20:13:40 +0700 Subject: [PATCH] fix: create leave request user commander and user oc fix: create leave handle lastSalary Amount while null value --- .../Controllers/LeaveRequestController.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index cb0d3e2d..d9485786 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -277,10 +277,14 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-008": { var lastSalary = profile.ProfileSalary; + var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + leaveRequest.LeaveSalary = (int)lastSalaryAmount; + leaveRequest.LeaveSalaryText = lastSalaryAmountText; + //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + //leaveRequest.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); - leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - leaveRequest.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); leaveRequest.LeaveBirthDate = profile.BirthDate; leaveRequest.LeaveGovernmentDate = profile.DateStart; @@ -297,10 +301,13 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-010": { var lastSalary = profile.ProfileSalary; - - leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - leaveRequest.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + leaveRequest.LeaveSalary = (int)lastSalaryAmount; + leaveRequest.LeaveSalaryText = lastSalaryAmountText; + //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + //leaveRequest.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); leaveRequest.CoupleDayName = req.CoupleDayName ?? ""; leaveRequest.CoupleDayPosition = req.CoupleDayPosition ?? ""; @@ -321,20 +328,22 @@ namespace BMA.EHR.Leave.Service.Controllers } // add dear and oc_data - 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 rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + 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; + //} + leaveRequest.LeaveTypeCode = leaveType.Code; leaveRequest.Dear = approver; leaveRequest.PositionName = profile.Position == null ? "" : profile.Position; leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName; - leaveRequest.OrganizationName = profile.Root ?? ""; + leaveRequest.OrganizationName = userOc; @@ -693,7 +702,7 @@ namespace BMA.EHR.Leave.Service.Controllers var lastSalary = profile.ProfileSalary; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); var approver = profile.Commander ?? ""; var userOc = profile.Root ?? ""; //if (rootOc != null)