hrms-api-backend/BMA.EHR.Application/Repositories/MessageQueue/MessageQueueRepository.cs

50 lines
1.5 KiB
C#
Raw Normal View History

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