using FastEndpoints; using FrameworkBLL.LoadTemplate; using FrameworkDAL.DTO.LoadTemplate; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.LoadTemplate { public class SaveLoadTemplate : BaseEndpoint> { private readonly ILoadTemplateBLL _LoadTemplateBLL; public SaveLoadTemplate(ILoadTemplateBLL LoadTemplateBLL) { _LoadTemplateBLL = LoadTemplateBLL; } public override void Configure() { Post("/LoadTemplate/SaveLoadTemplate"); AllowAnonymous(); } public record SaveLoadTemplateParameters( [property: FromHeader] string Login, [property: FromBody] LoadTemplateDTO LoadTemplateDTO ); protected override async Task> ExecuteAsync(SaveLoadTemplateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _LoadTemplateBLL.SaveLoadTemplate(req.LoadTemplateDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }