add message queue table for notification system

This commit is contained in:
Suphonchai Phoonsawat 2023-07-12 21:08:46 +07:00
parent 1c99718a30
commit 841bf32175
12 changed files with 21322 additions and 3 deletions

View file

@ -0,0 +1,49 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.Placement;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Repositories.MessageQueue
{
public class MessageQueueRepository : GenericRepository<Guid, MessageQueueEntity>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destuctor "
public MessageQueueRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Methods "
public async Task<List<MessageQueueEntity>> GetUnSentAsync(int count = 10)
{
var data = await _dbContext.Set<MessageQueueEntity>().Where(x => !x.IsSend)
.AsNoTracking()
.OrderBy(m => m.CreatedAt)
.Take(count)
.ToListAsync();
return data;
}
#endregion
}
}