65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
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<Guid, Placement>
|
|
{
|
|
#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<List<Placement>> GetCompetitivePlacementAsync()
|
|
{
|
|
try
|
|
{
|
|
var data = await _dbContext.Set<Placement>()
|
|
.Include(p => p.PlacementType)
|
|
.Where(p => p.PlacementType.Name == "สอบแข่งขัน")
|
|
.ToListAsync();
|
|
|
|
return data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<Placement>> GetQualifyingPlacementAsync()
|
|
{
|
|
var data = await _dbContext.Set<Placement>()
|
|
.Include(p => p.PlacementType)
|
|
.Where(p => p.PlacementType.Name != "สอบแข่งขัน")
|
|
.ToListAsync();
|
|
|
|
return data;
|
|
}
|
|
|
|
public async Task<IEnumerable<Placement>> FindByNameAsync(string name)
|
|
{
|
|
var data = await _dbContext.Set<Placement>().Where(x => x.Name == name).ToListAsync();
|
|
|
|
return data;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|