From 431d0981ae5208c03197ab718a1cf9de1028c826 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Sat, 2 Sep 2023 21:38:31 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20=E0=B8=9A=E0=B8=B1=E0=B8=99?= =?UTF-8?q?=E0=B8=97=E0=B8=B6=E0=B8=81=20=E0=B8=81=E0=B8=A3=E0=B8=93?= =?UTF-8?q?=E0=B8=B5=E0=B8=95=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89=20Token=20=E0=B9=80=E0=B8=9E=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=E0=B8=B3=E0=B9=84=E0=B8=9B=E0=B9=81=E0=B8=99?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=9E=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=95?= =?UTF-8?q?=E0=B8=B4=E0=B8=94=E0=B8=95=E0=B9=88=E0=B8=AD=20nodejs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/Commands/CommandRepository.cs | 4 ++-- .../Controllers/OrderController.cs | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 1807cf3f..68fbf57d 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1890,7 +1890,7 @@ namespace BMA.EHR.Application.Repositories.Commands #region " Command Receiver " - public async Task SaveSelectedReceiverAsync(Guid id, List selected) + public async Task SaveSelectedReceiverAsync(Guid id, List selected, string token = "") { try { @@ -1902,7 +1902,7 @@ namespace BMA.EHR.Application.Repositories.Commands if (command == null) throw new Exception(GlobalMessages.CommandNotFound); - var ap = (await GetReceiverForByCommndTypeAsync(command)).Where(x => selected.Contains(x.RefPlacementProfileId!.Value)); + var ap = (await GetReceiverForByCommndTypeAsync(command, token)).Where(x => selected.Contains(x.RefPlacementProfileId!.Value)); //var appointPeople = await _dbContext.Set() // .Include(x => x.Prefix) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 6de87780..779ff581 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -12,6 +12,7 @@ using BMA.EHR.Infrastructure.Persistence; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; +using System.Net; using System.Net.Http.Headers; using System.Security.Claims; @@ -2743,11 +2744,23 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> SaveCommandSelectReceiverAsync(Guid orderId, [FromBody] List selected) + public async Task> SaveCommandSelectReceiverAsync([FromHeader] string authorization, Guid orderId, [FromBody] List selected) { try { - await _repository.SaveSelectedReceiverAsync(orderId, selected); + var token = string.Empty; + if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue)) + { + // we have a valid AuthenticationHeaderValue that has the following details: + + var scheme = headerValue.Scheme; + token = headerValue.Parameter; + + // scheme will be "Bearer" + // parmameter will be the token itself. + } + + await _repository.SaveSelectedReceiverAsync(orderId, selected, token); return Success(); }