แก้รายชื่อแนบท้ายไม่แสดง

This commit is contained in:
Suphonchai Phoonsawat 2023-08-07 11:53:11 +07:00
parent 8a84d7faa8
commit 10207e76f0
5 changed files with 106 additions and 15 deletions

View 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
}
}