using System.Linq;
using Abp.EntityFrameworkCore;
using Abp.Runtime.Session;
using YGNT.QuestionLibrary.Core.Disciplines;
using YGNT.QuestionLibrary.Core.IRepositories;
using YGNT.QuestionLibrary.EntityFrameworkCore.Repositories.Filter;

namespace YGNT.QuestionLibrary.EntityFrameworkCore.Repositories
{
    public class DisciplineRepository : QuestionLibraryRepositoryBase<Discipline>, IDisciplineRepository
    {
        private readonly IDisciplineFilter _disciplineFilter;

        public DisciplineRepository(IDbContextProvider<QuestionLibraryDbContext> dbContextProvider, IDisciplineFilter disciplineFilter) : base(dbContextProvider)
        {
            _disciplineFilter = disciplineFilter;
        }

        protected override IQueryable<Discipline> GetQueryable()
        {
            return base.GetQueryable()
                .Where(x => _disciplineFilter.GetFilterQueryable().Contains(x));
        }
    }
}