public ActionResult Create(int id, Question question, string[] AnswerText, bool[] correctAnswer) { if (ModelState.IsValid) { //Jeg looper over answer text og laver svar, jeg bruger answer til loop, fordi correctAnswer //af en eller anden grund har en ekstra bool i enden af arrayet?? for (int i = 0; i < AnswerText.Length; i++) { Answer answer = new Answer { AnswerText = AnswerText[i], isCorrectAnswer = correctAnswer[i] }; question.Answers.Add(answer); } question.QuizId = id; db.Questions.Add(question); db.SaveChanges(); return RedirectToAction("Index","Quizzes"); } return View(question); }
public ActionResult _AnswerForm() { Answer answer = new Answer(); return PartialView(answer); }