Restructured query repositries to move ef logic from handlers

This commit is contained in:
2019-04-27 00:02:55 -04:00
parent 7be4075222
commit 1a95acac01
18 changed files with 169 additions and 59 deletions

View File

@@ -0,0 +1,26 @@
using BrightGlimmer.Data.Interfaces;
using BrightGlimmer.Domain;
using BrightGlimmer.Service.Queries;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace BrightGlimmer.Service.Handlers.QueryHandlers
{
public class GetStudentsQueryHandler : IRequestHandler<GetStudentsQuery, IEnumerable<Student>>
{
private readonly IQueryRepository<Student> repository;
public GetStudentsQueryHandler(IQueryRepository<Student> repository)
{
this.repository = repository;
}
public async Task<IEnumerable<Student>> Handle(GetStudentsQuery request, CancellationToken cancellationToken)
{
return await repository.Get().ToListAsync();
}
}
}