using FastEndpoints; using FrameworkBLL.SecurityQuestion; using FrameworkDAL.DTO.User; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; using static FrameworkSL.Endpoints.SecurityQuestion.SaveSecurityQuestion; namespace FrameworkSL.Endpoints.SecurityQuestion { public class SaveSecurityQuestion : BaseEndpoint> { private readonly ISecurityQuestionBLL _SecurityQuestionBLL; public SaveSecurityQuestion(ISecurityQuestionBLL SecurityQuestionBLL) { _SecurityQuestionBLL = SecurityQuestionBLL; } public override void Configure() { Post("/SecurityQuestion/SaveSecurityQuestion"); AllowAnonymous(); } public record SecurityQuestionParameters( [property: FromHeader] string Login, [property: FromBody] SecurityQuestionDTO SecurityQuestionDTO ); protected override async Task> ExecuteAsync(SecurityQuestionParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _SecurityQuestionBLL.SaveSecurityQuestion(req.SecurityQuestionDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }