public ActionResult AddAnswerPost(Question formModel, int Answer) { if (ModelState.IsValid) { var modelDb = QuestionRepository.Find(formModel.ID); var modelAnswer = AnswerRepository.Find(Answer); modelDb.Answers.Add(modelAnswer); if (this.TryUpdateModel(modelDb)) { QuestionRepository.Update(modelDb); QuestionRepository.Save(); //return RedirectToAction("Index"); } } FillDropdownValues(); return View(formModel); }
public ActionResult Create(Question model) { if(ModelState.IsValid) { QuestionRepository.Insert(model); QuestionRepository.Save(); //return RedirectToAction("Index"); } FillDropdownValues(); return View(model); }
public ActionResult EditPost(Question formModel) { if (ModelState.IsValid) { var modelDb = QuestionRepository.Find(formModel.ID); if(this.TryUpdateModel(modelDb)) { QuestionRepository.Update(modelDb); QuestionRepository.Save(); return RedirectToAction("Index"); } } FillDropdownValues(); return View(formModel); }