Major update
This commit is contained in:
26
divisions/Handlers/GetDivisionsQueryHandler.cs
Normal file
26
divisions/Handlers/GetDivisionsQueryHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Divisions.DbContexts;
|
||||
using Divisions.Entities;
|
||||
using Divisions.Helpers;
|
||||
using Divisions.Queries;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Divisions.Handlers
|
||||
{
|
||||
public class GetDivisionsQueryHandler : IRequestHandler<GetDivisionsQuery, PagedList<Division>>
|
||||
{
|
||||
private readonly DivisionsContext _dbContext;
|
||||
|
||||
public GetDivisionsQueryHandler(DivisionsContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
|
||||
}
|
||||
|
||||
public async Task<PagedList<Division>> Handle(GetDivisionsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return PagedList<Division>.ToPagedList(await _dbContext.Divisions.ToListAsync(), request.PageNumber, request.PageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user