示例#1
0
 public ActionResult ListQuiz()
 {
     var quizzes = QuizService.GetQuizzes();
     if (quizzes == null)
         quizzes = new Quiz[0];
     return PartialView(quizzes);
 }
示例#2
0
 public ActionResult ChooseQuiz()
 {
     var quizzes = QuizService.GetQuizzes();
     if (quizzes == null)
         quizzes = new Quiz[0];
     return View("ListQuiz", quizzes);
 }
示例#3
0
 public ActionResult ManageQuiz(Quiz model)
 {
     if (ModelState.IsValid)
     {
         QuizService.UpdateQuiz(model);
     }
     return RedirectToAction("Home", "User");
 }
示例#4
0
 public static Quiz AddQuiz(Quiz quiz)
 {
     using (QuizBuilderDb db = new QuizBuilderDb())
     {
         Quiz toAdd = quiz;
         db.Quizzes.Add(toAdd);
         db.SaveChanges();
         return toAdd;
     }
 }
示例#5
0
 public ActionResult CreateQuiz(Quiz model)
 {
     if (ModelState.IsValid)
     {
         QuizService.AddQuiz(model);
         return RedirectToAction("Default");
     }
     else
     {
         return RedirectToAction("Default");
     }
 }
示例#6
0
 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;
     }
 }