public JsonResult Delete(int id) { QuizRepository.Delete(id); QuizRepository.Save(); return(new JsonResult() { Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Create(Quiz model) { if (ModelState.IsValid) { QuizRepository.Insert(model); QuizRepository.Save(); return(RedirectToAction("Index")); } FillDropdownValues(); 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)); }