using FastEndpoints; using FrameworkBLL.SecurityQuestion; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.SecurityQuestion { public class DeleteSecurityQuestion : BaseEndpoint> { public readonly ISecurityQuestionBLL _SecurityQuestionBLL; public DeleteSecurityQuestion(ISecurityQuestionBLL ISecurityQuestionBLL) { _SecurityQuestionBLL = ISecurityQuestionBLL; } public override void Configure() { Delete("/SecurityQuestion/DeleteSecurityQuestion"); AllowAnonymous(); } public record DeleteSecurityQuestionParameters( [property: FromHeader] string Login, [property: QueryParam] int SecurityQuestionId ); protected override async Task> ExecuteAsync(DeleteSecurityQuestionParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SecurityQuestionBLL.DeleteSecurityQuestion(req.SecurityQuestionId, 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); } } } }