From 75ab503dfc6520d862a1a8396d77d07f5d611442 Mon Sep 17 00:00:00 2001 From: kieva Date: Wed, 8 Oct 2025 16:43:09 +0200 Subject: [PATCH] Ajouter PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint --- .../Material/GetAllMaterialsEndpoint | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint diff --git a/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint b/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint new file mode 100644 index 0000000..e59d51c --- /dev/null +++ b/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint @@ -0,0 +1,28 @@ +using API.DTO.Material.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace API.Endpoints.Material; + +public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/material"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await appDbContext.Materials + .Select(a => new GetMaterialDto + { + Id = a.Id, + Name = a.Name, + Quantity = a.Quantity, + WarehouseId = a.WarehouseId, + } + ).ToListAsync(ct); + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file