using FastEndpoints; using FrameworkBLL.DocumentMap; using FrameworkDAL.DTO.DocumentMap; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.DocumentMap { public class SaveDocumentMap : BaseEndpoint> { private readonly IDocumentMapBLL _DocumentMapBLL; public SaveDocumentMap(IDocumentMapBLL DocumentMapBLL) { _DocumentMapBLL = DocumentMapBLL; } public override void Configure() { Post("/DocumentMap/SaveDocumentMap"); AllowAnonymous(); } public record SaveDocumentMapParameters( [property: FromHeader] string Login, [property: FromBody] DocumentMapDTO DocumentMapDTO ); protected override async Task> ExecuteAsync(SaveDocumentMapParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _DocumentMapBLL.SaveDocumentMap(req.DocumentMapDTO, 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); } } } }