public ActionResult Create([Bind(Include = "Id,Text")] Document document) { if (ModelState.IsValid) { db.Documents.Add(new Document(document.Text)); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(document)); }
public ActionResult Create([Bind(Include = "Id,Text,CategoryId")] Document document) { if (ModelState.IsValid) { db.Documents.Add(new Document(document.Text)); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", document.CategoryId); return(View(document)); }