using FastEndpoints; using FrameworkBLL.Operation; using FrameworkDAL.DTO.Project; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Operation { public class SaveOperation : BaseEndpoint> { private readonly IOperationBLL _OperationBLL; public SaveOperation(IOperationBLL OperationBLL) { _OperationBLL = OperationBLL; } public override void Configure() { Post("/Operation/SaveOperation"); AllowAnonymous(); } public record SaveOperationParameters( [property: FromHeader] string Login, [property: FromBody] OperationDTO OperationDTO ); protected override async Task> ExecuteAsync(SaveOperationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _OperationBLL.SaveOperation(req.OperationDTO, 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); } } } }