From 085b6849803b72838321bbdd52dcfc52194b0e99 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 8 Sep 2023 11:31:56 +0700 Subject: [PATCH] fix select placement round --- .../Repositories/Commands/CommandRepository.cs | 5 +++++ .../Repositories/PlacementRepository.cs | 16 ++++++++++++++++ .../Controllers/OrderController.cs | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 404635e5..7fb242e9 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -182,6 +182,7 @@ namespace BMA.EHR.Application.Repositories.Commands .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.Organization) //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => x.Placement.Id == command.Placement.Id) .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") .Where(x => x.Draft! == true) @@ -246,6 +247,7 @@ namespace BMA.EHR.Application.Repositories.Commands .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.Organization) //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => x.Placement.Id == command.Placement.Id) .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") .Where(x => x.Draft! == true) @@ -311,6 +313,7 @@ namespace BMA.EHR.Application.Repositories.Commands .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.Organization) //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => x.Placement.Id == command.Placement.Id) .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") .Where(x => x.Draft! == true) @@ -375,6 +378,7 @@ namespace BMA.EHR.Application.Repositories.Commands .Include(x => x.Prefix) .Include(x => x.OrganizationPosition) .ThenInclude(x => x!.Organization) + .Where(x => x.Placement.Id == command.Placement.Id) .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") .Where(x => x.Draft! == true) @@ -5981,6 +5985,7 @@ namespace BMA.EHR.Application.Repositories.Commands throw; } } + #endregion } diff --git a/BMA.EHR.Application/Repositories/PlacementRepository.cs b/BMA.EHR.Application/Repositories/PlacementRepository.cs index 9dd3f03a..49f1175c 100644 --- a/BMA.EHR.Application/Repositories/PlacementRepository.cs +++ b/BMA.EHR.Application/Repositories/PlacementRepository.cs @@ -43,6 +43,22 @@ namespace BMA.EHR.Application.Repositories } } + public async Task> GetAllPlacementAsync() + { + try + { + var data = await _dbContext.Set() + .Include(p => p.PlacementType) + .ToListAsync(); + + return data; + } + catch + { + throw; + } + } + public async Task> GetQualifyingPlacementAsync() { var data = await _dbContext.Set() diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 2a8342b6..030c4f02 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -2601,7 +2601,9 @@ namespace BMA.EHR.Command.Service.Controllers { try { - var rawData = commandCode.Trim().ToUpper() == "C-PM-01" ? await _placementRepository.GetCompetitivePlacementAsync() : await _placementRepository.GetQualifyingPlacementAsync(); + var rawData = commandCode.Trim().ToUpper() == "C-PM-01" ? await _placementRepository.GetCompetitivePlacementAsync() : + commandCode.Trim().ToUpper() == "C-PM-02" ? await _placementRepository.GetQualifyingPlacementAsync() : + await _placementRepository.GetAllPlacementAsync(); var data = rawData.Select(x => new