Added endpoint to get products under their limit

This commit is contained in:
Cristiano
2025-12-18 14:41:45 +01:00
parent 29e2036965
commit 3487baad87
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using AutoMapper;
using FastEndpoints;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
namespace PyroFetes.Endpoints.Products;
public class GetAllProductsUnderLimitEndpoint(ProductsRepository productsRepository) : EndpointWithoutRequest<List<GetProductDto>>
{
public override void Configure()
{
Get("/products/underLimit");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await productsRepository.ProjectToListAsync<GetProductDto>(new GetProductsUnderLimitSpec(), ct), ct);
}
}