แก้บั้ก และเพิ่ม api inbox noti
This commit is contained in:
parent
060765d373
commit
aacbcfee32
6 changed files with 220 additions and 5 deletions
|
|
@ -0,0 +1,59 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||
{
|
||||
public class NotificationRepository : GenericRepository<Guid, Notification>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public NotificationRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<Notification>> GetMyNotificationAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var profile = await _dbContext.Set<Profile>()
|
||||
.FirstOrDefaultAsync(p => p.KeycloakId == Guid.Parse(UserId!));
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
var data = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.ReceiverUserId == profile.Id)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue