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