-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathGetPersonList.cs
More file actions
24 lines (21 loc) · 937 Bytes
/
GetPersonList.cs
File metadata and controls
24 lines (21 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace QueryKit.WebApiTestProject.Features;
using Configuration;
using Database;
using Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
public static class GetPersonList
{
public sealed record Query(string FilterInput, string SortInput, IQueryKitConfiguration? QueryKitConfig = null) : IRequest<List<TestingPerson>>;
public sealed class Handler(TestingDbContext testingDbContext) : IRequestHandler<Query, List<TestingPerson>>
{
public async Task<List<TestingPerson>> Handle(Query request, CancellationToken cancellationToken)
{
var queryablePeople = testingDbContext.People;
var appliedQueryable = queryablePeople
.ApplyQueryKitFilter(request.FilterInput, request.QueryKitConfig)
.ApplyQueryKitSort(request.SortInput, request.QueryKitConfig);
return await appliedQueryable.ToListAsync(cancellationToken);
}
}
}