public ActionResult AddAnswer(AnswerViewModel answer) { if (ModelState.IsValid) { Answer newAnswer = new Answer() { IdQuestion = answer.IdQuestion, AnswerDescription = answer.AnswerDescription, IsTrue = answer.IsTrue }; answerRepository.CreateNewAnswer(newAnswer); answerRepository.SaveChanges(); return RedirectToAction("ListAnswers", "Admin", new { idQuestion = answer.IdQuestion }); } else { return RedirectToAction("AddAnswer", "Admin"); } }
public ActionResult EditAnswer(AnswerViewModel answer) { Answer activeAnswer = answerRepository.GetAnswerByID(answer.IdAnswer); if (activeAnswer != null && answer.AnswerDescription != null) { activeAnswer.AnswerDescription = answer.AnswerDescription; activeAnswer.IsTrue = answer.IsTrue; answerRepository.SaveChanges(); } return RedirectToAction("ListAnswers", "Admin", new { idQuestion = answer.IdQuestion }); }