54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using BMA.EHR.Application.Common.Interfaces;
|
|
using BMA.EHR.Domain.Models.Commands.Core;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace BMA.EHR.Application.Repositories.Commands
|
|
{
|
|
public class PlacementCommandRepository : GenericRepository<Guid, Command>
|
|
{
|
|
#region " Fields "
|
|
|
|
private readonly IApplicationDBContext _dbContext;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
#endregion
|
|
|
|
#region " Constructor and Destuctor "
|
|
|
|
public PlacementCommandRepository(IApplicationDBContext dbContext,
|
|
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
|
{
|
|
_dbContext = dbContext;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Methods "
|
|
|
|
public async Task<List<CommandReceiver>> GetReceiverByCommmandIdAsync(Guid Id)
|
|
{
|
|
try
|
|
{
|
|
var command = await _dbContext.Set<Command>()
|
|
.Include(x => x.Receivers)
|
|
.FirstOrDefaultAsync(x => x.Id == Id);
|
|
|
|
if(command == null)
|
|
{
|
|
return new List<CommandReceiver>();
|
|
}
|
|
else
|
|
return command.Receivers;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|