เพิ่มรับคืนเครื่องราช

This commit is contained in:
Kittapath 2023-09-26 17:51:18 +07:00
parent 59f782e8cf
commit 1619a502d4
22 changed files with 33518 additions and 41 deletions

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Responses;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
@ -28,7 +29,7 @@ namespace BMA.EHR.Application.Repositories
#region " Methods "
public string GetOrganizationNameFullPath(Guid id, bool showRoot = false, bool descending = false,string seperator = " ")
public string GetOrganizationNameFullPath(Guid id, bool showRoot = false, bool descending = false, string seperator = " ")
{
try
{
@ -96,6 +97,62 @@ namespace BMA.EHR.Application.Repositories
throw;
}
}
private List<string> GetOcNameFullPath(Guid id, bool showRoot = false)
{
try
{
var ocList = new List<string>();
var oc = (from o in _dbContext.Set<OrganizationEntity>().Include(x => x.Parent).Include(x => x.OrganizationOrganization).Where(x => x.OrganizationOrganization != null).AsQueryable()
join oc_name in _dbContext.Set<OrganizationOrganization>().AsQueryable() on o.OrganizationOrganization.Id equals oc_name.Id
where o.Parent != null
select new
{
Id = o.Id,
Name = oc_name.Name,
o.IsActive,
o.Parent
}).FirstOrDefault(x => x.Id == id && x.IsActive);
if (oc == null)
return ocList;
ocList.Add(oc.Name);
if (oc.Parent?.Id != null)
{
ocList.AddRange(GetOcNameFullPath(oc.Parent.Id, showRoot));
}
return ocList;
}
catch
{
throw;
}
}
private string FindOCFullPath(Guid id, bool showRoot = false)
{
try
{
var ocList = GetOcNameFullPath(id, showRoot);
var ret = String.Empty;
foreach (var oc in ocList)
{
ret = oc + "/" + ret;
}
if (ret.Length > 2)
ret = ret.Substring(0, ret.Length - 1);
return ret;
}
catch
{
throw;
}
}
#endregion
}