public ActionResult ListQuiz() { var quizzes = QuizService.GetQuizzes(); if (quizzes == null) quizzes = new Quiz[0]; return PartialView(quizzes); }
public ActionResult ChooseQuiz() { var quizzes = QuizService.GetQuizzes(); if (quizzes == null) quizzes = new Quiz[0]; return View("ListQuiz", quizzes); }
public ActionResult ManageQuiz(Quiz model) { if (ModelState.IsValid) { QuizService.UpdateQuiz(model); } return RedirectToAction("Home", "User"); }
public static Quiz AddQuiz(Quiz quiz) { using (QuizBuilderDb db = new QuizBuilderDb()) { Quiz toAdd = quiz; db.Quizzes.Add(toAdd); db.SaveChanges(); return toAdd; } }
public ActionResult CreateQuiz(Quiz model) { if (ModelState.IsValid) { QuizService.AddQuiz(model); return RedirectToAction("Default"); } else { return RedirectToAction("Default"); } }
public static Quiz UpdateQuiz(Quiz updatedQuiz) { using (QuizBuilderDb db = new QuizBuilderDb()) { Quiz currentQuiz = db.Quizzes.Find(updatedQuiz.QuizID); if (currentQuiz != null) { currentQuiz.QuizName = updatedQuiz.QuizName; currentQuiz.QuizName = updatedQuiz.QuizAuthor; currentQuiz.QuestionPoolID = updatedQuiz.QuestionPoolID; db.SaveChanges(); return currentQuiz; } else return currentQuiz; } }