using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.AssessmentPaper; using TMSSL.EndPoints.AssessmentPaper; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.AssessmentPaper { public class DeleteAssessmentPaper : BaseEndpoint> { private readonly IAssessmentPaperBLL _AssessmentPaperBLL; public DeleteAssessmentPaper(IAssessmentPaperBLL AssessmentPaperBLL) { _AssessmentPaperBLL = AssessmentPaperBLL; } public override void Configure() { Delete("/AssessmentPaper/DeleteAssessmentPaper"); AllowAnonymous(); } public record DeleteAssessmentPaperParameters( [property: QueryParam] int AssessmentPaperId, [property: FromHeader] string Login ); protected override string? GetCacheKey(DeleteAssessmentPaperParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.AssessmentPaperId, EntityConstant.OBJECTASSESSMENTPAPER, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override bool ShouldInvalidateCache(DeleteAssessmentPaperParameters req, LoginDTO loginDTO) => true; protected override async Task> ExecuteAsync(DeleteAssessmentPaperParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _AssessmentPaperBLL.DeleteAssessmentPaper(req.AssessmentPaperId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }