finalisation des endpoints
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
using PF3.DTO.Truck.Request;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3;
|
||||
|
||||
namespace ApiLibrary.Endpoints.Truck;
|
||||
|
||||
public class DeleteTruckEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdTruckDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/api/trucks/{@Id}", x => new { x.Id });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(IdTruckDto req, CancellationToken ct)
|
||||
{
|
||||
var truck = await pf3DbContext.Trucks.FirstOrDefaultAsync(a => a.Id == req.Id, ct);
|
||||
|
||||
pf3DbContext.Trucks.Remove(truck);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.OkAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user