fix issue #1575
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m52s

This commit is contained in:
Suphonchai Phoonsawat 2026-05-07 16:14:01 +07:00
parent bc3bba547f
commit 1739aa8057
2 changed files with 76 additions and 3 deletions

View file

@ -213,6 +213,79 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
}
}
public async Task<List<AdditionalCheckRequest>> GetAdditionalCheckRequestsByAdminRole2(DateTime startDate, DateTime endDate, string role, string nodeId, int? node, string? keyword, string? status)
{
try
{
var data = await _dbContext.Set<AdditionalCheckRequest>().AsQueryable()
.Where(x => (x.CheckDate.Date >= startDate.Date && x.CheckDate.Date <= endDate.Date))
.OrderByDescending(x => x.CreatedAt.Date)
.ToListAsync();
if(!string.IsNullOrEmpty(status))
data = data.Where(x => x.Status == status).ToList();
if (!string.IsNullOrEmpty(keyword))
{
data = data.Where(x =>
(
(x.Prefix ?? "") + (x.FirstName ?? "") + " " + (x.LastName ?? "")).Contains(keyword)
|| x.Description.Contains(keyword)
).ToList();
}
if (role == "OWNER")
{
node = null;
}
if (role == "OWNER" || role == "CHILD")
{
data = data
.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))))))
.ToList();
}
else if (role == "BROTHER")
{
data = data
.Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))
.ToList();
}
else if (role == "ROOT")
{
data = data
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
}
// else if (role == "PARENT")
// {
// data = data
// .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList();
// }
else if (role == "NORMAL")
{
data = data.Where(x =>
node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) &&
(x.Child1DnaId == Guid.Empty || x.Child1DnaId == null) :
node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) &&
(x.Child2DnaId == Guid.Empty || x.Child2DnaId == null) :
node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) &&
(x.Child3DnaId == Guid.Empty || x.Child3DnaId == null) :
node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) &&
(x.Child4DnaId == Guid.Empty || x.Child4DnaId == null) :
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
true
).ToList();
}
return data;
}
catch
{
throw;
}
}
#endregion
}
}