Get and return stuff from the database

This commit is contained in:
moarten
2026-04-10 22:33:31 +02:00
parent 87d15b99ed
commit 7bce78aa0c
4 changed files with 47 additions and 7 deletions

View File

@@ -1,14 +1,25 @@
using Cortex.Mediator.Queries;
using Lutra.Application.Interfaces;
using Lutra.Application.Models.Supermarkten;
using Microsoft.EntityFrameworkCore;
namespace Lutra.Application.Supermarkten
{
public sealed partial class GetSupermarkten
{
public sealed class Handler : IQueryHandler<Query, Response>
public sealed class Handler(ILutraDbContext context) : IQueryHandler<Query, Response>
{
public async Task<Response> Handle(Query request, CancellationToken cancellationToken)
{
return new Response { Supermarkten = [] };
var supermarkten = await context.Supermarkten
.AsNoTracking()
.OrderBy(s => s.Naam)
.Skip(request.Skip)
.Take(request.Take)
.Select(s => new Supermarkt { Naam = s.Naam })
.ToListAsync(cancellationToken);
return new Response { Supermarkten = supermarkten };
}
}
}