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 { #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> GetReceiverByCommmandIdAsync(Guid Id) { try { var command = await _dbContext.Set() .Include(x => x.Receivers) .FirstOrDefaultAsync(x => x.Id == Id); if(command == null) { return new List(); } else return command.Receivers; } catch { throw; } } #endregion } }