From e340beb79de0c7a89ef2415fce73614208f70c3c Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Wed, 6 Sep 2023 11:52:48 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2?= =?UTF-8?q?=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B9=80=E0=B8=81=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=A7=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=87=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 | 44 +++++++++++-------- .../Commands/SearchProfileCommandRequest.cs | 2 +- .../Controllers/OrderController.cs | 2 +- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index eef0eae1..c963a9ba 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -3737,28 +3737,34 @@ namespace BMA.EHR.Application.Repositories.Commands #endregion - public async Task GetCommandProfileAsync(Guid commandTypeId, int year, string? posno) + public async Task GetCommandProfileAsync(string commandType, int year, string? posno) { try { - var commandType = await _dbContext.Set() - .FirstOrDefaultAsync(x => x.Id == commandTypeId); - - if (commandType == null) - throw new Exception(GlobalMessages.CommandTypeNotFound); - - var profile = await _dbContext.Set() - .Where(x => x.CitizenId == "0000000000001") - .Select(x => new - { - Id = x.Id, - CitizenId = x.CitizenId, - FullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}", - PosNo = x.PosNo == null ? null : x.PosNo.Name, - Position = x.Position == null ? null : x.Position.Name, - }) - .ToListAsync(); - return profile; + var data = (from r in await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + .Include(x => x.Profile) + .ThenInclude(x => x.PosNo) + .Include(x => x.Profile) + .ThenInclude(x => x.Position) + .ToListAsync() + where r.CommandTypeName == commandType + where r.CommandNo.Contains((year + 543).ToString()) + where posno == null || posno == "" ? r.Id != null : r.CommandNo.Contains(posno) + where r.Profile != null + select new + { + Id = r.Profile.Id, + CitizenId = r.Profile.CitizenId, + FullName = $"{r.Profile.Prefix.Name}{r.Profile.FirstName} {r.Profile.LastName}", + PosNo = r.Profile.PosNo == null ? null : r.Profile.PosNo.Name, + Position = r.Profile.Position == null ? null : r.Profile.Position.Name, + }) + .Distinct() + .OrderBy(x => x.CitizenId) + .ToList(); + return data; } catch { diff --git a/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs index 1af7fb64..21df5d26 100644 --- a/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs +++ b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs @@ -2,7 +2,7 @@ { public class SearchProfileCommandRequest { - public Guid CommandTypeId { get; set; } + public string CommandType { get; set; } public int Year { get; set; } diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 75235641..8b0810d7 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -3439,7 +3439,7 @@ namespace BMA.EHR.Command.Service.Controllers { try { - var data = await _repository.GetCommandProfileAsync(req.CommandTypeId, req.Year, req.Posno); + var data = await _repository.GetCommandProfileAsync(req.CommandType, req.Year, req.Posno); return Success(data); }