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(); }