public void EditQuiz_Post_RedirectToPreviewQuiz() { EditQuizBindingModel model = new EditQuizBindingModel() { Id = 1, Title = "ChangedTitle" }; this.controller.WithCallTo(c => c.EditQuiz(model)) .ShouldRedirectTo(c => c.PreviewQuiz(1)); }
public ActionResult EditQuiz([Bind(Include = "Id,Title")] EditQuizBindingModel model) { if (ModelState.IsValid) { this.service.EditQuiz(model); return(this.RedirectToAction("PreviewQuiz", "Quizzes", new { area = "Admin", id = model.Id })); } EditQuizViewModel viewModel = this.service.GetEditViewModel(model.Id); return(this.View(viewModel)); }
public void EditQuiz(EditQuizBindingModel model) { Quiz quiz = this.GetQuiz(model.Id); if (quiz == null) { throw new ArgumentNullException(nameof(model.Id), "There is no Quiz with such Id."); } quiz.Title = model.Title; this.Context.SaveChanges(); }