using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.QuestionBank; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.QuestionBank { public class GetQuestionsForSection : BaseEndpoint> { private readonly IQuestionBankBLL _QuestionBankBLL; public GetQuestionsForSection(IQuestionBankBLL questionBankBLL) { _QuestionBankBLL = questionBankBLL; } public override void Configure() { Get("/QuestionBank/GetQuestionsForSection"); AllowAnonymous(); } public record GetQuestionsForSectionParameters( [property: QueryParam] int AssessmentPaperId, [property: QueryParam] int PaperSectionId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetQuestionsForSectionParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(GetQuestionsForSectionParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _QuestionBankBLL.GetQuestionsForSection(req.AssessmentPaperId, req.PaperSectionId, 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); } } } }