public IActionResult AddProblem(AddProblemBindingModel bindingModel) { if (ModelState.IsValid) { this.problemsService.AddProblem(bindingModel); return(Redirect($"/{Area.Fun}/{Paths.Games}/{Actions.ManageCodeWizard}")); ; } return(View(bindingModel)); }
//Tested public GameProblem AddProblem(AddProblemBindingModel bindingModel) { var problem = mapper.Map <GameProblem>(bindingModel); this.context.GameProblems.Add(problem); this.context.SaveChanges(); problem.RightAnswer = GetRightAnswerString(bindingModel); problem.Choices = this.AddChoices(bindingModel, problem); this.context.SaveChanges(); return(problem); }
public AddProblemBindingModel GetTestAddProblemBM(ChoiceEnum choice) { var bm = new AddProblemBindingModel() { Content = "Test question", RightAnswer = choice, AnswerA = "TestA", AnswerB = "TestB", AnswerC = "TestC", AnswerD = "TestD", }; return(bm); }