Ajouter PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint

This commit is contained in:
2025-10-08 16:43:09 +02:00
parent 52f0e84323
commit 75ab503dfc

View File

@@ -0,0 +1,28 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetMaterialDto>>
{
public override void Configure()
{
Get("/material");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetMaterialDto> 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);
}
}