Files
PyroFetes/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs
2025-11-20 16:33:56 +01:00

21 lines
594 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Products;
public class GetAllProductsEndpoint(ProductsRepository productsRepository) : EndpointWithoutRequest<List<GetProductDto>>
{
public override void Configure()
{
Get("/products");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await productsRepository.ProjectToListAsync<GetProductDto>(ct), ct);
}
}