using FastEndpoints; using FrameworkBLL.WebForm; using FrameworkSL.Endpoints.WebForm; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.WebForm { public class GetWebForm : BaseEndpoint { private readonly IWebFormBLL _WebFormBLL; public GetWebForm(IWebFormBLL WebFormBLL) { _WebFormBLL = WebFormBLL; } public override void Configure() { Get("/WebForm/GetWebForm"); AllowAnonymous(); } public record GetWebFormParameters( [property: QueryParam] int WebFormId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetWebFormParameters GetWebFormParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetWebFormParameters.WebFormId!, EntityConstant.OBJECTWEBFORM, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetWebFormParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _WebFormBLL.GetWebForm(req.WebFormId, 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); } } } }