using PF3.DTO.Truck.Request; using PF3.DTO.Truck.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; using PF3; namespace PF3.Endpoints.Truck; public class GetTruckEndpoint(PF3DbContext pf3DbContext) : Endpoint { public override void Configure() { Get("/api/trucks/{@Id}"); } public override async Task HandleAsync(IdTruckDto req, CancellationToken ct) { var truck = await pf3DbContext.Trucks .Where(t => t.Id == req.Id) .Select(t => new ReadTruckDto { Id = t.Id, Type = t.Type, MaxExplosiveCapacity = t.MaxExplosiveCapacity, Sizes = t.Sizes, Statut = t.Statut, ShowId = t.ShowId }) .FirstOrDefaultAsync(ct); if (truck is null) { await Send.NotFoundAsync(ct); return; } await Send.OkAsync(truck, ct); } }