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