forked from sanchezvem/PyroFetes
AJout des DTO et endpoint sur le nouveau git
This commit is contained in:
33
PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs
Normal file
33
PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using API.DTO.Warehouse.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class GetAllWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetWarehouseDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/warehouses");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetWarehouseDto> responseDto = await pyrofetesdbcontext.Warehouses
|
||||
.Select(w => new GetWarehouseDto
|
||||
{
|
||||
Id = w.Id,
|
||||
Name = w.Name,
|
||||
MaxWeight = w.MaxWeight,
|
||||
Current = w.Current,
|
||||
MinWeight = w.MinWeight,
|
||||
Adress = w.Address,
|
||||
ZipCode = w.ZipCode,
|
||||
City = w.City
|
||||
})
|
||||
.ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user