using FastEndpoints; using FrameworkBLL.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 DeleteFile : BaseEndpoint> { public readonly IFileBLL _FileBLL; public DeleteFile(IFileBLL IFileBLL) { _FileBLL = IFileBLL; } public override void Configure() { Delete("/File/DeleteFile"); AllowAnonymous(); } public record DeleteFileParameters( [property: FromHeader] string Login, [property: QueryParam] int FileId ); protected override async Task> ExecuteAsync(DeleteFileParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _FileBLL.DeleteFile(req.FileId, 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); } } } }