using CMSBLL.Content; using CMSDAL.DTO.Content; using FastEndpoints; 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 CMSSL.Endpoints.Content { public class SaveContent : BaseEndpoint> { private readonly IContentBLL _ContentBLL; public SaveContent(IContentBLL ContentBLL) { _ContentBLL = ContentBLL; } public override void Configure() { Post("/Content/SaveContent"); AllowAnonymous(); } public record SaveContentParameters( [property: FromHeader] string Login, [property: FromBody] ContentDTO ContentDTO ); protected override async Task> ExecuteAsync(SaveContentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ContentBLL.SaveContent(req.ContentDTO, LoginDTO!, ct); 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); } } } }