get บรรจุ ตามตำแหน่ง

This commit is contained in:
Kittapath 2023-07-06 14:37:13 +07:00
parent 85bc0fd359
commit c9e36b1792
6 changed files with 10505 additions and 18 deletions

View file

@ -210,5 +210,33 @@ namespace BMA.EHR.Application.Repositories
}
#endregion
public List<Guid> GetAllIdByRoot(Guid? id)
{
try
{
var ret = new List<Guid>();
if(id == null)
return ret;
var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
if (oc != null)
ret.Add(oc.Id);
var child = _context.Organizations.AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
if (child.Any())
{
foreach (var item in child)
{
ret.AddRange(GetAllIdByRoot(item.Id));
}
}
return ret;
}
catch
{
throw;
}
}
}
}