using FrameworkBLL.ServiceRequest; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using FastEndpoints; using FrameworkDAL.DTO.ServiceRequest; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ServiceRequest { public class GetServiceRequest : BaseEndpoint> { private readonly IServiceRequestBLL _ServiceRequestBLL; public GetServiceRequest(IServiceRequestBLL serviceRequestBLL) { _ServiceRequestBLL = serviceRequestBLL; } public override void Configure() { Get("/ServiceRequest/GetServiceRequest"); AllowAnonymous(); } public record GetServiceRequestParameters( [property: FromHeader] string Login, [property: QueryParam] int ServiceRequestId ); //protected override string? GetCacheKey(GetServiceRequestParameters parameters, LoginDTO loginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(parameters.ServiceRequestId, EntityConstant.OBJECTSERVICEREQUEST, CacheKeyLevel.USER_LEVEL, loginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetServiceRequestParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ServiceRequestBLL.GetServiceRequest(req.ServiceRequestId, 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 ); } } } }