using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.PaperSection; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.PaperSection { public class DeletePaperSectionsByAssessmentPaper : BaseEndpoint> { private readonly IPaperSectionBLL _PaperSectionBLL; public DeletePaperSectionsByAssessmentPaper(IPaperSectionBLL paperSectionBLL) { _PaperSectionBLL = paperSectionBLL; } public override void Configure() { Delete("/PaperSection/DeletePaperSectionsByAssessmentPaper"); AllowAnonymous(); } public record DeletePaperSectionsByAssessmentPaperParameters( [property: QueryParam] int AssessmentPaperId, [property: FromHeader] string Login ); protected override string? GetCacheKey(DeletePaperSectionsByAssessmentPaperParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(DeletePaperSectionsByAssessmentPaperParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PaperSectionBLL.DeletePaperSectionsByPaper(req.AssessmentPaperId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }