Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
        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 });
        }