using PF3.DTO.Truck.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; using PF3; namespace PF3.Endpoints.Truck; public class GetAllTrucksEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest> { public override void Configure() { Get("/api/trucks"); } public override async Task HandleAsync(CancellationToken ct) { var trucks = await pf3DbContext.Trucks.ToListAsync(ct); var result = trucks .Select(truck => new ReadTruckDto { Id = truck.Id, Type = truck.Type, MaxExplosiveCapacity = truck.MaxExplosiveCapacity, Sizes = truck.Sizes, Statut = truck.Statut, ShowId = truck.ShowId }) .ToList(); await Send.OkAsync(result, ct); } }