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