using FastEndpoints; using FrameworkBLL.SecurityQuestion; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.SecurityQuestion { public class GetSecurityQuestion : BaseEndpoint> { private readonly ISecurityQuestionBLL _SecurityQuestionBLL; public GetSecurityQuestion(ISecurityQuestionBLL SecurityQuestionBLL) { _SecurityQuestionBLL = SecurityQuestionBLL; } public override void Configure() { Get("/SecurityQuestion/GetSecurityQuestion"); AllowAnonymous(); } public record GetSecurityQuestionParameters( [property: FromHeader] string Login, [property: QueryParam] int SecurityQuestionId ); protected override string? GetCacheKey(GetSecurityQuestionParameters GetSecurityQuestionParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetSecurityQuestionParameters.SecurityQuestionId!, EntityConstant.OBJECTSECURITYQUESTION, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetSecurityQuestionParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _SecurityQuestionBLL.GetSecurityQuestion(parameters.SecurityQuestionId, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }