public IActionResult GenerateUserSpecifiedQuadraticEquationWorksheet( [FromBody] WorksheetGeneratorParametersWithCustomParameters <QuadraticEquation, QuadraticEquationGeneratorParameters> worksheetParameters) { Func <QuadraticEquationGeneratorParameters, QuadraticEquationGenerator> generatorConstructor = parameters => new QuadraticEquationGenerator(randomIntegerGenerator, parameters); return(GenerateuserSpecifiedWorksheet(worksheetParameters, generatorConstructor)); }
public IActionResult GenerateUserSpecifiedSimultaneousEquationsWorksheet( [FromBody] WorksheetGeneratorParametersWithCustomParameters <LinearSimultaneousEquations, LinearSimultaneousEquationsGeneratorParameters> worksheetParameters) { Func <LinearSimultaneousEquationsGeneratorParameters, LinearSimultaneousEquationsGenerator> generatorConstructor = parameters => new LinearSimultaneousEquationsGenerator(randomIntegerGenerator, parameters); return(GenerateuserSpecifiedWorksheet(worksheetParameters, generatorConstructor)); }
private IActionResult GenerateuserSpecifiedWorksheet <TGeneratorParamaters, TQuestion>( WorksheetGeneratorParametersWithCustomParameters <TQuestion, TGeneratorParamaters> worksheetParameters, Func <TGeneratorParamaters, IQuestionGenerator <IQuestion> > generatorConstructor) where TGeneratorParamaters : IValidatableObject where TQuestion : IQuestion { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(ControllerTryCatchBlocks.ReturnBadRequestOnFailedToGenerateExceptionLoggingAllOthers(logger, () => { var generators = worksheetParameters.QuestionGeneratorParameters .Select(parameter => generatorConstructor(parameter)) .ToList(); BuildAndSendPdf(generators, worksheetParameters.EmailAddress.Address); return Ok(ModelState); }, BadRequest, worksheetParameters)); }