Files
PyroFetes-Sujet1/PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs
2025-10-09 16:55:29 +02:00

28 lines
735 B
C#

using PyroFetes.DTO.Brand.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Brand;
public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetBrandDto>>
{
public override void Configure()
{
Get("/api/brands");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands
.Select(a => new GetBrandDto
{
Id = a.Id,
Name = a.Name,
}
).ToListAsync(ct);
await Send.OkAsync(responseDto, ct);
}
}