From ccaaf25dbc935754035140939e4f26ab7b89328e Mon Sep 17 00:00:00 2001 From: kieva Date: Wed, 8 Oct 2025 16:38:00 +0200 Subject: [PATCH] Ajouter PyroFetes/Endpoints/Color/GetAllColorsEndpoint --- .../Endpoints/Color/GetAllColorsEndpoint | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 PyroFetes/Endpoints/Color/GetAllColorsEndpoint diff --git a/PyroFetes/Endpoints/Color/GetAllColorsEndpoint b/PyroFetes/Endpoints/Color/GetAllColorsEndpoint new file mode 100644 index 0000000..0d1a089 --- /dev/null +++ b/PyroFetes/Endpoints/Color/GetAllColorsEndpoint @@ -0,0 +1,26 @@ +using API.DTO.Color.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace API.Endpoints.Color; + +public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/colors"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await appDbContext.Colors + .Select(a => new GetColorDto + { + Id = a.Id, + Label = a.Label, + } + ).ToListAsync(ct); + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file