This commit is contained in:
parent
06a6019e97
commit
ed0bde9780
7 changed files with 169 additions and 6 deletions
|
|
@ -308,6 +308,46 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetListLeaveRequestForAdminAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, string role, string? nodeId, int? node)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.LeaveStatus != "DRAFT")
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.AsQueryable();
|
||||
|
||||
if (year != 0)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
rawData = rawData.Where(x => x.LeaveStatus == status);
|
||||
|
||||
if (startDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate >= startDate);
|
||||
|
||||
if (endDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveEndDate <= endDate);
|
||||
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData = rawData
|
||||
//.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId) : (node == null ? true : true))))))
|
||||
//.Where(x => node == 0 ? x.Child1DnaId == null : (node == 1 ? x.Child2DnaId == null : (node == 2 ? x.Child3DnaId == null : (node == 3 ? x.Child4DnaId == null : true))));
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
|
||||
}
|
||||
|
||||
|
||||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, List<Guid> keycloakIdList)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
|
|
|
|||
|
|
@ -780,6 +780,29 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue