From ae488fcfdb0027b73b4c6c87d3014c8c6b3baf61 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 11 Oct 2023 12:32:27 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B8=99=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=20=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 29 ++++++++++--------- .../Controllers/OrderController.cs | 8 ++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index ef3c4184..d027c991 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -6189,15 +6189,14 @@ namespace BMA.EHR.Application.Repositories.Commands case "C-PM-01": case "C-PM-02": case "C-PM-03": - case "c-PM-04": + case "C-PM-04": salary = await GetPlacementSalaryAsync(item.RefPlacementProfileId.Value); break; default: - salary = await GetCommandReceiverSalary(item.RefPlacementProfileId.Value); + salary = await GetCommandReceiverSalary(item.RefPlacementProfileId.Value, item.Amount, item.MouthSalaryAmount, item.PositionSalaryAmount); break; } - var receiver = new CommandReceiver { Sequence = seq, @@ -6769,27 +6768,29 @@ namespace BMA.EHR.Application.Repositories.Commands #region " Placement " - public async Task GetCommandReceiverSalary(Guid recordId) + public async Task GetCommandReceiverSalary(Guid recordId, Double? _Amount, Double? _MouthSalaryAmount, Double? _PositionSalaryAmount) { try { var cmdReceiver = await _dbContext.Set() .FirstOrDefaultAsync(x => x.Id == recordId); + double SalaryAmount = 0; + double PositionSalaryAmount = 0; + double MonthSalaryAmount = 0; + if (cmdReceiver == null) + { return new PlacementSalaryResponse { - SalaryAmount = 0, - PositionSalaryAmount = 0, - MonthSalaryAmount = 0 + SalaryAmount = _Amount == null ? 0 : _Amount.Value, + PositionSalaryAmount = _MouthSalaryAmount == null ? 0 : _MouthSalaryAmount.Value, + MonthSalaryAmount = _PositionSalaryAmount == null ? 0 : _PositionSalaryAmount.Value, }; + } var profile = await _dbContext.Set() .Include(x => x.Salaries) .FirstOrDefaultAsync(p => p.CitizenId == cmdReceiver.CitizenId); - double? SalaryAmount = 0; - double? PositionSalaryAmount = 0; - double? MonthSalaryAmount = 0; - if (profile != null && profile.Salaries != null && profile.Salaries.Count() > 0) { SalaryAmount = profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value : 0; @@ -6799,9 +6800,9 @@ namespace BMA.EHR.Application.Repositories.Commands return new PlacementSalaryResponse { - SalaryAmount = cmdReceiver.Amount != null && cmdReceiver.Amount != 0 ? cmdReceiver.Amount.Value : SalaryAmount ?? 0, - PositionSalaryAmount = cmdReceiver.PositionSalaryAmount != null && cmdReceiver.PositionSalaryAmount != 0 ? cmdReceiver.PositionSalaryAmount.Value : PositionSalaryAmount ?? 0, - MonthSalaryAmount = cmdReceiver.MouthSalaryAmount != null && cmdReceiver.MouthSalaryAmount != 0 ? cmdReceiver.MouthSalaryAmount.Value : MonthSalaryAmount ?? 0, + SalaryAmount = cmdReceiver.Amount != null && cmdReceiver.Amount != 0 ? cmdReceiver.Amount.Value : SalaryAmount, + PositionSalaryAmount = cmdReceiver.PositionSalaryAmount != null && cmdReceiver.PositionSalaryAmount != 0 ? cmdReceiver.PositionSalaryAmount.Value : PositionSalaryAmount, + MonthSalaryAmount = cmdReceiver.MouthSalaryAmount != null && cmdReceiver.MouthSalaryAmount != 0 ? cmdReceiver.MouthSalaryAmount.Value : MonthSalaryAmount, }; } catch diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 127c81c2..3ab913ce 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -2929,7 +2929,7 @@ namespace BMA.EHR.Command.Service.Controllers { foreach (var r in receivers) { - var salary = await _repository.GetCommandReceiverSalary(r.PersonalId); + var salary = await _repository.GetCommandReceiverSalary(r.PersonalId, r.SalaryAmount, r.MonthSalaryAmount, r.PositionSalaryAmount); r.SalaryAmount = salary.SalaryAmount; r.PositionSalaryAmount = salary.PositionSalaryAmount; r.MonthSalaryAmount = salary.MonthSalaryAmount; @@ -3001,7 +3001,7 @@ namespace BMA.EHR.Command.Service.Controllers { foreach (var r in receivers) { - var salary = await _repository.GetCommandReceiverSalary(r.PersonalId); + var salary = await _repository.GetCommandReceiverSalary(r.PersonalId, r.SalaryAmount, r.MonthSalaryAmount, r.PositionSalaryAmount); r.SalaryAmount = salary.SalaryAmount; r.PositionSalaryAmount = salary.PositionSalaryAmount; r.MonthSalaryAmount = salary.MonthSalaryAmount; @@ -3345,7 +3345,7 @@ namespace BMA.EHR.Command.Service.Controllers var payload_str = JsonConvert.SerializeObject(payload); - return Success(payload_str); + return Success(payload_str); } catch { @@ -3579,7 +3579,7 @@ namespace BMA.EHR.Command.Service.Controllers data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value); break; default: - data = await _repository.GetCommandReceiverSalary(personalId); + data = await _repository.GetCommandReceiverSalary(personalId, record.Amount, record.MouthSalaryAmount, record.PositionSalaryAmount); break; }