เพิ่ม Header
This commit is contained in:
parent
c9e2c91ab4
commit
6a9e069920
21 changed files with 154 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
|
|
@ -19,18 +20,20 @@ namespace BMA.EHR.Application.Repositories
|
|||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly DbSet<T> _dbSet;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public GenericRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_dbSet = _dbContext.Set<T>();
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -58,6 +61,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.GetAsync(apiPath);
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
|
|
@ -85,6 +89,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsync(apiPath, stringContent);
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
|
|
@ -112,6 +117,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsync(apiPath, stringContent);
|
||||
return _res.IsSuccessStatusCode;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue