fix bug upload
api ออกคำสั่ง ส่ง inbox and noti
This commit is contained in:
parent
9ff5725be4
commit
c99cb5344e
11 changed files with 13843 additions and 4 deletions
102
BMA.EHR.Application/Repositories/OrganizationCommonRepository.cs
Normal file
102
BMA.EHR.Application/Repositories/OrganizationCommonRepository.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class OrganizationCommonRepository
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public OrganizationCommonRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public string GetOrganizationNameFullPath(Guid id, bool showRoot = false, bool descending = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ocList = GetOCWithFullPath(id, showRoot);
|
||||
if (descending)
|
||||
ocList = ocList.OrderBy(x => x.Order).ToList();
|
||||
|
||||
var ret = String.Empty;
|
||||
foreach (var oc in ocList)
|
||||
{
|
||||
ret = oc.Name + " " + ret;
|
||||
}
|
||||
if (ret.Length > 2)
|
||||
ret = ret.Substring(0, ret.Length - 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public List<OrganizationItem> GetOCWithFullPath(Guid id, bool showRoot = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ocList = new List<OrganizationItem>();
|
||||
|
||||
var ocData = _dbContext.Set<OrganizationEntity>()
|
||||
.Include(x => x.OrganizationOrganization)
|
||||
.Include(x => x.Parent)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.OrganizationOrganization!.Name,
|
||||
ParentId = x.Parent!.Id
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
if (ocData != null)
|
||||
{
|
||||
ocList.Add(new OrganizationItem { Id = ocData.Id, Name = ocData.Name });
|
||||
|
||||
//if (!showRoot)
|
||||
//{
|
||||
// if (!oc.IsRoot)
|
||||
// ocList.Add(new OrganizationItem { Id = oc.OCId, Name = oc.OrganizationName });
|
||||
//}
|
||||
//else
|
||||
// ocList.Add(new OrganizationItem { Id = oc.OCId, Name = oc.OrganizationName });
|
||||
|
||||
if (ocData.ParentId != null)
|
||||
{
|
||||
ocList.AddRange(GetOCWithFullPath(ocData.ParentId, showRoot));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ocList;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue