using CMSBLL.ContentType; using CMSDAL.DTO.ContentType; 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.ContentType { public class SaveContentType : BaseEndpoint> { private readonly IContentTypeBLL _ContentTypeBLL; public SaveContentType(IContentTypeBLL ContentTypeBLL) { _ContentTypeBLL = ContentTypeBLL; } public override void Configure() { Post("/ContentType/SaveContentType"); AllowAnonymous(); } public record SaveContentTypeParameters( [property: FromHeader] string Login, [property: FromBody] ContentTypeDTO ContentTypeDTO ); protected override async Task> ExecuteAsync(SaveContentTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ContentTypeBLL.SaveContentType(req.ContentTypeDTO, 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); } } } }