Fix Bug บันทึก กรณีต้องใช้ Token เพื่อนำไปแนบเพื่อติดต่อ nodejs

This commit is contained in:
Suphonchai Phoonsawat 2023-09-02 21:38:31 +07:00
parent 7edd71e404
commit 431d0981ae
2 changed files with 17 additions and 4 deletions

View file

@ -1890,7 +1890,7 @@ namespace BMA.EHR.Application.Repositories.Commands
#region " Command Receiver "
public async Task SaveSelectedReceiverAsync(Guid id, List<Guid> selected)
public async Task SaveSelectedReceiverAsync(Guid id, List<Guid> 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<PlacementProfile>()
// .Include(x => x.Prefix)

View file

@ -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<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync(Guid orderId, [FromBody] List<Guid> selected)
public async Task<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync([FromHeader] string authorization, Guid orderId, [FromBody] List<Guid> 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();
}