using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Domain.Models.Placement; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; namespace BMA.EHR.Application.Repositories { public class PlacementRepository : GenericRepository { #region " Fields " private readonly IApplicationDBContext _dbContext; private readonly IHttpContextAccessor _httpContextAccessor; #endregion #region " Constructor and Destructor " public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; } #endregion #region " Methods " public async Task> GetCompetitivePlacementAsync() { try { var data = await _dbContext.Set() .Include(p => p.PlacementType) .Where(p => p.PlacementType.Name == "สอบแข่งขัน") .ToListAsync(); return data; } catch { throw; } } public async Task> GetAllPlacementAsync() { try { var data = await _dbContext.Set() .Include(p => p.PlacementType) .ToListAsync(); return data; } catch { throw; } } public async Task> GetQualifyingPlacementAsync() { var data = await _dbContext.Set() .Include(p => p.PlacementType) .Where(p => p.PlacementType.Name != "สอบแข่งขัน") .ToListAsync(); return data; } public async Task> FindByNameAsync(string name) { var data = await _dbContext.Set().Where(x => x.Name == name).ToListAsync(); return data; } #endregion } }