All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m19s
1464 lines
50 KiB
C#
1464 lines
50 KiB
C#
using BMA.EHR.Application.Common.Interfaces;
|
|
using BMA.EHR.Application.Responses.Insignias;
|
|
using BMA.EHR.Application.Responses.Leaves;
|
|
using BMA.EHR.Application.Responses.Organizations;
|
|
using BMA.EHR.Application.Responses.Profiles;
|
|
using BMA.EHR.Domain.Models.HR;
|
|
using BMA.EHR.Domain.Models.MetaData;
|
|
using BMA.EHR.Domain.Models.Organizations;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BMA.EHR.Application.Repositories
|
|
{
|
|
public class UserProfileRepository : GenericRepository<Guid, Profile>
|
|
{
|
|
#region " Fields "
|
|
|
|
private readonly IApplicationDBContext _dbContext;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
#endregion
|
|
|
|
#region " Costructor and Destructor "
|
|
|
|
public UserProfileRepository(IApplicationDBContext dbContext,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
|
{
|
|
_dbContext = dbContext;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Methods "
|
|
|
|
public async Task<OrganizationEntity?> GetOrganizationById(Guid id)
|
|
{
|
|
var data = await _dbContext.Set<OrganizationEntity>().AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
return data;
|
|
}
|
|
|
|
public async Task<OrganizationAgency?> GetOrgAgencyById(Guid id)
|
|
{
|
|
var data = await _dbContext.Set<OrganizationAgency>().AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
return data;
|
|
}
|
|
|
|
public async Task<OrganizationGovernmentAgency?> GetOrgGovAgencyById(Guid id)
|
|
{
|
|
var data = await _dbContext.Set<OrganizationGovernmentAgency>().AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
return data;
|
|
}
|
|
|
|
public async Task<List<GetProfileByRootIdDto>> GetOfficerProfileByRootIdAsync(Guid rootId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/unauthorize/root/officer/{rootId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(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
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByRootIdAsync(Guid rootId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/root/employee/{rootId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(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
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByPositionAsync(Guid rootId, string[] empPosId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/unauthorize/find/employee/position";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var body = new
|
|
{
|
|
rootId,
|
|
empPosId
|
|
};
|
|
|
|
//var bodyJson = JsonConvert.SerializeObject(bodyRaw);
|
|
|
|
// สร้าง HTTP content
|
|
//var body = new StringContent(bodyJson, Encoding.UTF8, "application/json");
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdNewAsync(Guid keycloakId, string? accessToken,CancellationToken cancellationToken = default)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey, cancellationToken);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdNew2Async(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak2/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<GetProfileLeaveByKeycloakDto?> GetProfileLeaveByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/profile-leave/keycloak/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileLeaveByKeycloakResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileLeaveByKeycloakDto?> GetProfileLeaveReportByKeycloakIdAsync(Guid keycloakId, string? accessToken, string? report)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/profile-leave/keycloak";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
keycloakId = keycloakId,
|
|
report = report
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileLeaveByKeycloakResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByProfileIdAsync(Guid profileId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/profile/{profileId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<bool> UpdateDutyTimeAsync(Guid profileId, Guid roundId, DateTime effectiveDate, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/update-dutytime";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var body = new
|
|
{
|
|
EffevtiveDate = effectiveDate,
|
|
RoundId = roundId,
|
|
ProfileId = profileId
|
|
};
|
|
|
|
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
|
|
return apiResult;
|
|
//var profile = await _dbContext.Set<Profile>()
|
|
// .AsQueryable()
|
|
// .Include(x => x.Prefix)
|
|
// .FirstOrDefaultAsync(x => x.Id == profileId);
|
|
|
|
//if (profile == null)
|
|
//{
|
|
// throw new Exception(GlobalMessages.DataNotFound);
|
|
//}
|
|
//else
|
|
//{
|
|
// var fullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}";
|
|
// Console.WriteLine(fullName);
|
|
|
|
// profile.DutyTimeId = roundId;
|
|
// profile.DutyTimeEffectiveDate = effectiveDate;
|
|
|
|
// await UpdateAsync(profile);
|
|
|
|
// return true;
|
|
//}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloak(string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficer(string? accessToken, int? node, string? nodeId, bool isAll)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithNoneValidateKeycloakAllOfficer(string? accessToken, int? node, string? nodeId, bool isAll)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/none-validate-keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficerRetireFilter(string? accessToken, int? node, string? nodeId, bool isAll, bool? isRetirement)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
isRetirement = isRetirement,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllEmployee(string? accessToken, int? node, string? nodeId, bool isAll)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-employee";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithNoneValidateKeycloakAllEmployee(string? accessToken, int? node, string? nodeId, bool isAll)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/none-validate-keycloak-all-employee";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficerAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
revisionId = revisionId,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/none-validate-keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
revisionId = revisionId,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-role";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
role = role,
|
|
revisionId = revisionId,
|
|
reqNode = reqNode,
|
|
reqNodeId = reqNodeId,
|
|
//startDate = startDate,
|
|
//endDate = endDate
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRolev2(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev2";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
role = role,
|
|
// revisionId = revisionId,
|
|
reqNode = reqNode,
|
|
reqNodeId = reqNodeId,
|
|
// startDate = startDate,
|
|
// endDate = endDate
|
|
date = endDate
|
|
};
|
|
Console.WriteLine(body);
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return new List<GetProfileByKeycloakIdRootDto>();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRolev3(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev3";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
role = role,
|
|
// revisionId = revisionId,
|
|
reqNode = reqNode,
|
|
reqNodeId = reqNodeId,
|
|
startDate = startDate,
|
|
endDate = endDate
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRolev4(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev4";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
role = role,
|
|
// revisionId = revisionId,
|
|
reqNode = reqNode,
|
|
reqNodeId = reqNodeId,
|
|
// startDate = startDate,
|
|
// endDate = endDate
|
|
date = endDate
|
|
};
|
|
Console.WriteLine(body);
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return new List<GetProfileByKeycloakIdRootDto>();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficerRetireFilterAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, bool? isRetirement, string? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
isRetirement = isRetirement,
|
|
revisionId = revisionId,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficerRetireFilterAndRevisionAndDate(string? accessToken, int? node, string? nodeId, bool isAll, bool? isRetirement, string? revisionId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer/date";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
isRetirement = isRetirement,
|
|
revisionId = revisionId,
|
|
startDate = startDate,
|
|
endDate = endDate,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllEmployeeAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-employee";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
revisionId = revisionId,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, string? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/none-validate-keycloak-all-employee";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
isAll = isAll,
|
|
revisionId = revisionId,
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/employee-by-admin-role";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
node = node,
|
|
nodeId = nodeId,
|
|
role = role,
|
|
revisionId = revisionId,
|
|
reqNode = reqNode,
|
|
reqNodeId = reqNodeId,
|
|
startDate = startDate,
|
|
endDate = endDate
|
|
};
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/search";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
citizenId = citizenId,
|
|
firstName = firstName,
|
|
lastName = lastName,
|
|
role = role,
|
|
nodeId = nodeId,
|
|
node = node,
|
|
page = page,
|
|
pageSize = pageSize,
|
|
};
|
|
|
|
var profiles = new List<GetProfileByKeycloakIdRootDto>();
|
|
var total = 0;
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultAddTotalDto>(apiResult);
|
|
if (raw != null && raw.Result != null)
|
|
{
|
|
profiles = raw.Result.Data;
|
|
total = raw.Result.Total;
|
|
}
|
|
}
|
|
|
|
return new GetProfileByKeycloakIdRootAddTotalDto { Data = profiles, Total = total };
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/search-employee";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
citizenId = citizenId,
|
|
firstName = firstName,
|
|
lastName = lastName,
|
|
role = role,
|
|
nodeId = nodeId,
|
|
node = node,
|
|
page = page,
|
|
pageSize = pageSize,
|
|
};
|
|
|
|
var profiles = new List<GetProfileByKeycloakIdRootDto>();
|
|
var total = 0;
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultAddTotalDto>(apiResult);
|
|
if (raw != null && raw.Result != null)
|
|
{
|
|
profiles.AddRange(raw.Result.Data);
|
|
total = raw.Result.Total;
|
|
}
|
|
}
|
|
|
|
return new GetProfileByKeycloakIdRootAddTotalDto { Data = profiles, Total = total };
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public string GetUserFullName(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/user-fullname/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetUserFullNameResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public Guid GetUserOCId(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/user-oc/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetUserOCIdDto>(apiResult.Result);
|
|
if (raw == null || raw.RootId == null)
|
|
return Guid.Empty;
|
|
return raw.RootId;
|
|
}
|
|
|
|
return Guid.Empty;
|
|
|
|
//var data = _dbContext.Set<ProfilePosition>()
|
|
// .Include(x => x.Profile)
|
|
// .Include(x => x.OrganizationPosition)
|
|
// .ThenInclude(x => x.Organization)
|
|
// .Where(x => x.Profile!.KeycloakId == keycloakId)
|
|
// .FirstOrDefault();
|
|
|
|
//if (data == null)
|
|
// throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
//return data.OrganizationPosition!.Organization!.Id;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetUserOCAllDto?> GetUserOCAll(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/user-oc-all/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetUserOCAllResultDto>(apiResult);
|
|
return raw?.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<GetUserOCIdDto?> GetUserOC(Guid keycloakId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/user-oc/{keycloakId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetUserOCIdResultDto>(apiResult.Result);
|
|
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public Guid? GetRootOcId(Guid ocId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/root-oc/{ocId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetRootOCIdResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
|
|
//var data = _dbContext.Set<OrganizationEntity>()
|
|
// .FirstOrDefault(o => o.Id == ocId);
|
|
|
|
//return data == null ? Guid.Empty : data.OrganizationAgencyId;
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public GetOrganizationResponseDTO? GetOc(Guid ocId, int level, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/find/allv2";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
nodeId = ocId,
|
|
node = level
|
|
|
|
};
|
|
|
|
var apiResult = PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey).Result;
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetOrganizationResponseResultDTO>(apiResult);
|
|
if (raw != null && raw.Result != null)
|
|
{
|
|
return raw.Result;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public GetProfileByIdDto GetOfficerProfileById(Guid id, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile/{id}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public GetProfileByIdDto GetEmployeeProfileById(Guid id, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile-employee/{id}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<GetProfileByKeycloakIdDto?> GetOfficerProfileByCitizenId(string citizenId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/citizenId/{citizenId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken, Guid? revisionId)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/active/root/{revisionId}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetActiveRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<Guid?> GetLastRevision(string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/active/root/latest";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetLastRevisionDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<GetActiveRootDto>> GetActiveRootLatestAsync(string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/unauthorize/active/root/all";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetActiveRootResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile/insignia";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task PostInsigniaMessageToSocket(string message, string userId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/through-socket/notify";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var body = new
|
|
{
|
|
message = message,
|
|
userId = userId
|
|
};
|
|
|
|
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task PostProfileEmpInsigniaAsync(PostProfileEmpInsigniaDto body, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile-employee/insignia";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var profiles = new List<SearchProfileDto>();
|
|
|
|
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task<GetIsOfficerDto> GetIsOfficerRootAsync(string? accessToken, string sys)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/workflow/keycloak/isofficer-root/{sys}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetIsOfficerResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
return new GetIsOfficerDto { isOfficer = false, isStaff = false, isDirector = false };
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task<List<GetMarkStatusDto>> GetInsigniaRequestsProfileAsync(string[] profileIds, string type, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/dotnet/find/insignia-requests-profile/{type}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var body = new
|
|
{
|
|
profileIds
|
|
};
|
|
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
|
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetMarkStatusResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public GetOrgProfileByProfileIdDto GetOrgProfileByProfileId(Guid id, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile/org-user/{id}";
|
|
var apiKey = _configuration["API_KEY"];
|
|
|
|
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
|
if (apiResult.Result != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetOrgProfileByProfileIdResultDto>(apiResult.Result);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
public async Task<List<GetProfileSalaryDto>> GetProfileSalaryById(Guid profileId, string? accessToken)
|
|
{
|
|
try
|
|
{
|
|
var apiPath = $"{_configuration["API"]}/org/profile/insignia/position";
|
|
var apiKey = _configuration["API_KEY"];
|
|
var body = new
|
|
{
|
|
profileId = profileId.ToString(),
|
|
};
|
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey);
|
|
if (apiResult != null)
|
|
{
|
|
var raw = JsonConvert.DeserializeObject<GetProfileSalaryResultDto>(apiResult);
|
|
if (raw != null)
|
|
return raw.Result;
|
|
}
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|