示例#1
0
 public IActionResult GetQuadraticEquation()
 {
     return(ControllerTryCatchBlocks.LoggingAllExceptions(logger, () =>
     {
         var equationGenerator = new QuadraticEquationGenerator(randomIntegerGenerator);
         return Ok(equationGenerator.GenerateQuestionAndAnswer());
     }));
 }
示例#2
0
        public IActionResult GetPolynomialEquation(int degree)
        {
            var x = ControllerTryCatchBlocks.LoggingAllExceptions(logger, () =>
            {
                var equationGenerator = new PolynomialEquationGenerator(randomIntegerGenerator, new PolynomialEquationGeneratorParameters(degree: degree));
                return(Ok(equationGenerator.GenerateQuestionAndAnswer()));
            });

            return(x);
        }
        private IActionResult GenerateDefaultWorksheet(BasicWorksheetGeneratorparameters parameters, IQuestionGenerator <IQuestion> generator)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(ControllerTryCatchBlocks.LoggingAllExceptions(logger, () =>
            {
                var generators = Enumerable.Range(0, parameters.NumberOfQuestions)
                                 .Select(t => generator)
                                 .ToList();

                BuildAndSendPdf(generators, parameters.EmailAddress.Address);
                return Ok(ModelState);
            }, new { parameters, generator }));
        }