fix : ต่อ API ระยยลา
This commit is contained in:
parent
66d491a2af
commit
be1c390bb8
10 changed files with 142 additions and 54 deletions
|
|
@ -61,18 +61,31 @@ namespace BMA.EHR.Application.Repositories
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<Profile?> GetProfileByKeycloakIdAsync(Guid keycloakId)
|
||||
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<Profile>().AsQueryable()
|
||||
.Include(p => p.Prefix)
|
||||
.Include(p => p.Position)
|
||||
.Include(p => p.PositionLevel)
|
||||
.Include(p => p.Salaries)
|
||||
.FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
|
||||
|
||||
return data;
|
||||
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
//var data = await _dbContext.Set<Profile>().AsQueryable()
|
||||
// .Include(p => p.Prefix)
|
||||
// .Include(p => p.Position)
|
||||
// .Include(p => p.PositionLevel)
|
||||
// .Include(p => p.Salaries)
|
||||
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
|
||||
|
||||
//return data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue