public ActionResult AddQuestion(int id) { FillDropdownValues(); var model = QuizRepository.Find(id); return(View(model)); }
public JsonResult DeleteQuestion(int id, int quizId) { var modelQuestion = QuestionRepository.Find(id); var modelQuiz = QuizRepository.Find(quizId); modelQuiz.Questions.Remove(modelQuestion); QuizRepository.Update(modelQuiz); QuizRepository.Save(); return(new JsonResult() { Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult EditPost(Quiz formModel) { if (ModelState.IsValid) { var modelDb = QuizRepository.Find(formModel.ID); if (this.TryUpdateModel(modelDb)) { QuizRepository.Update(modelDb); QuizRepository.Save(); return(RedirectToAction("Index")); } } FillDropdownValues(); return(View(formModel)); }
public ActionResult AddQuestionPost(Quiz formModel, int Question) { if (ModelState.IsValid) { var modelDb = QuizRepository.Find(formModel.ID); var modelQuestion = QuestionRepository.Find(Question); modelDb.Questions.Add(modelQuestion); if (this.TryUpdateModel(modelDb)) { QuizRepository.Update(modelDb); QuizRepository.Save(); //return RedirectToAction("Index"); } } FillDropdownValues(); return(View(formModel)); }
public ActionResult Details(int id) { var model = QuizRepository.Find(id); return(View(model)); }