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