public ActionResult EditQuestion(QuestionViewModel question) { Question activeQuestion = questionRepository.GetQuestionByID(question.QuestionId); if (activeQuestion != null && question.QuestionDetails.Question1 != null) { activeQuestion.IdCategory = question.CategoryId; activeQuestion.IdSubcategory = question.SubcatetegoryId; activeQuestion.NoStars = question.QuestionDetails.NoStars; activeQuestion.Question1 = question.QuestionDetails.Question1; questionRepository.SaveChanges(); } return RedirectToAction("ListQuestions", "Admin"); }
public ActionResult AddQuestion(QuestionViewModel question) { if (ModelState.IsValid) { Question newQuestion = new Question() { IdCategory = question.CategoryId, IdSubcategory = question.SubcatetegoryId, Question1 = question.QuestionDetails.Question1, NoStars = question.QuestionDetails.NoStars }; questionRepository.CreateNewQuestion(newQuestion); questionRepository.SaveChanges(); return RedirectToAction("ListQuestions", "Admin"); } else { return RedirectToAction("AddQuestion", "Admin"); } }