using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.AssessmentQuestion; using TMSSL.EndPoints.AssessmentQuestion; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.AssessmentQuestion { public class GetAssessmentQuestion : BaseEndpoint> { private readonly IAssessmentQuestionBLL _AssessmentQuestionBLL; public GetAssessmentQuestion(IAssessmentQuestionBLL AssessmentQuestionBLL) { _AssessmentQuestionBLL = AssessmentQuestionBLL; } public override void Configure() { Get("/AssessmentQuestion/GetAssessmentQuestion"); AllowAnonymous(); } public record GetAssessmentQuestionParameters( [property: QueryParam] int AssessmentQuestionId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetAssessmentQuestionParameters req, LoginDTO loginDTO) { return KeyGenerator.KeyGeneration(req.AssessmentQuestionId, EntityConstant.OBJECTASSESMENTQUESTION, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } protected override async Task> ExecuteAsync(GetAssessmentQuestionParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _AssessmentQuestionBLL.GetAssessmentQuestion(req.AssessmentQuestionId, 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); } } } }