using FastEndpoints; using FrameworkBLL.Page; using FrameworkDAL.DTO.Page; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Page { public class SavePage : BaseEndpoint> { private readonly IPageBLL _PageBLL; public SavePage(IPageBLL PageBLL) { _PageBLL = PageBLL; } public override void Configure() { Post("/Page/SavePage"); AllowAnonymous(); } public record SavePageParameters( [property: FromHeader] string Login, [property: FromBody] PageDTO PageDTO ); protected override async Task> ExecuteAsync(SavePageParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PageBLL.SavePage(req.PageDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }