แก้รายชื่อแนบท้ายไม่แสดง
This commit is contained in:
parent
8a84d7faa8
commit
10207e76f0
5 changed files with 106 additions and 15 deletions
55
BMA.EHR.Application/Repositories/UserProfileRepository.cs
Normal file
55
BMA.EHR.Application/Repositories/UserProfileRepository.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class UserProfileRepository : GenericRepository<Guid, Profile>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Costructor and Destructor "
|
||||
|
||||
public UserProfileRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public Guid GetUserOCId(Guid keycloakId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<ProfilePosition>()
|
||||
.Include(x => x.Profile)
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.Organization)
|
||||
.Where(x => x.Profile!.KeycloakId == keycloakId)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (data == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
return data.OrganizationPosition!.Organization!.Id;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue