SHARE
TWEET

Untitled

a guest Feb 24th, 2012 23 Never
  1. public ActionResult Create(Question question)
  2. {
  3.     if (ModelState.IsValid)
  4.     {
  5.         question.Answers = new List<Answer>();
  6.         question.Answers.Add(new Answer { AnswerText = "MyAnswer" });
  7.         db.Questions.Add(question);
  8.         db.SaveChanges();
  9.         return RedirectToAction("Index");  
  10.     }
  11.     return View(question);
  12. }
RAW Paste Data
Top