using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using LogisticsBLL.Vehicle; using LogisticsDAL.DTO.Vehicle; using static GB5Shared.GB5Constant.Constant; namespace LogisticsSL.EndPoints.Vehicle { public class SaveVehicle : BaseEndpoint> { private readonly IVehicleBLL _VehicleBLL; public SaveVehicle(IVehicleBLL VehicleBLL) { _VehicleBLL = VehicleBLL; } public override void Configure() { Post("/Vehicle/SaveVehicle"); AllowAnonymous(); } public record SaveVehicleParameters( [property: FromHeader] string Login, [property: FromBody] VehicleDTO VehicleDTO ); protected override async Task> ExecuteAsync(SaveVehicleParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VehicleBLL.SaveVehicle(req.VehicleDTO, 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); } } } }