using System; using MediatR; using Microsoft.EntityFrameworkCore; using Seasons.DbContexts; using Seasons.Entities; using Seasons.Helpers; using Seasons.Queries; namespace Seasons.Handlers { public class GetSeasonsQueryHandler : IRequestHandler> { private readonly SeasonsContext _dbContext; public GetSeasonsQueryHandler(SeasonsContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); } public async Task> Handle(GetSeasonsQuery request, CancellationToken cancellationToken) { var seasons = await _dbContext.Seasons.ToListAsync(); return PagedList.ToPagedList(await _dbContext.Seasons.ToListAsync(), request.PageNumber, request.PageSize); } } }