using FastEndpoints; using FrameworkBLL.ReportViewer; using FrameworkDAL.DTO.ReportViewer; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ReportViewer { public class SaveReportViewWithFields : BaseEndpoint> { private readonly IReportViewBLL _bll; public SaveReportViewWithFields(IReportViewBLL bll) => _bll = bll; public override void Configure() { Post("/ReportView/SaveReportViewWithFields"); AllowAnonymous(); } public record SaveReportViewWithFieldsParameters( [property: FromHeader] string Login, [property: FromBody] ReportViewDTO ReportViewDTO ); protected override async Task> ExecuteAsync( SaveReportViewWithFieldsParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.SaveReportViewWithFields(req.ReportViewDTO, 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); } } } }