using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using LogisticsBLL.Booking; using static GB5Shared.GB5Constant.Constant; namespace LogisticsSL.EndPoints.Booking { public class GetBooking : BaseEndpoint> { private readonly IBookingBLL _BookingBLL; public GetBooking(IBookingBLL IBookingBLL) { _BookingBLL = IBookingBLL; } public override void Configure() { Get("/Booking/GetBooking"); AllowAnonymous(); } public record GetBookingParameters( [property: FromHeader] string Login, [property: QueryParam] int BookingId ); //protected override string? GetCacheKey(GetBookingParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.BookingId!, EntityConstant.OBJECTBOOKING, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetBookingParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _BookingBLL.GetBooking(req.BookingId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }