public ActionResult ListQuestion()
 {
     var questions = QuestionService.GetQuestions();
     if (questions == null)
         questions = new Question[0];
     return PartialView(questions);
 }
 public static Question AddQuestion(Question question)
 {
     using (QuizBuilderDb db = new QuizBuilderDb())
     {
         Question toAdd = question;
         db.Questions.Add(toAdd);
         db.SaveChanges();
         return toAdd;
     }
 }
 public ActionResult CreateQuestion(Question model)
 {
     if (ModelState.IsValid)
     {
         QuestionService.AddQuestion(model);
         return RedirectToAction("Home", "User");
     }
     else
     {
         return RedirectToAction("Home", "User");
     }
 }
 public static Question UpdateQuestion(Question updatedQuestion)
 {
     using (QuizBuilderDb db = new QuizBuilderDb())
     {
         Question currentQuestion = db.Questions.Find(updatedQuestion.QuestionID);
         if (currentQuestion != null)
         {
             currentQuestion.QuestionContent = updatedQuestion.QuestionContent;
             currentQuestion.QuestionTypeID = updatedQuestion.QuestionTypeID;
             currentQuestion.AnswerContent = updatedQuestion.AnswerContent;
             db.SaveChanges();
             return currentQuestion;
         }
         else
             return currentQuestion;
     }
 }
 public ActionResult ManageQuestion(Question model)
 {
     if (ModelState.IsValid)
     {
         QuestionService.UpdateQuestion(model);
     }
     return RedirectToAction("Home", "User");
 }