Beispiel #1
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);
        }
Beispiel #2
0
        public IActionResult GetPolynomialEquation([FromBody] PolynomialEquationGeneratorParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(ControllerTryCatchBlocks.ReturnBadRequestOnFailedToGenerateExceptionLoggingAllOthers(logger, () =>
            {
                var equationGenerator = new PolynomialEquationGenerator(randomIntegerGenerator, parameters);
                return Ok(equationGenerator.GenerateQuestionAndAnswer());
            },
                                                                                                        BadRequest));
        }