using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using LogisticsBLL.Vehicle; using static GB5Shared.GB5Constant.Constant; namespace LogisticsSL.EndPoints.Vehicle { public class DeleteVehicle : BaseEndpoint> { private readonly IVehicleBLL _VehicleBLL; public DeleteVehicle(IVehicleBLL IVehicleBLL) { _VehicleBLL = IVehicleBLL; } public override void Configure() { Delete("/Vehicle/DeleteVehicle"); AllowAnonymous(); } public record DeleteVehicleParameters( [property: FromHeader] string Login, [property: QueryParam] int VehicleId ); protected override async Task> ExecuteAsync(DeleteVehicleParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VehicleBLL.DeleteVehicle(req.VehicleId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }