public ActionResult Create([Bind(Include = "Id,Name")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create(Book book) { if (ModelState.IsValid) { db.Books.Add(book); db.SaveChanges(); return(RedirectToAction("Index")); } return(View("Save", book)); }
public ActionResult Create([Bind(Include = "BookID,Title,Publisheddate,Description,ISNB,CategoryID")] Book book) { if (ModelState.IsValid) { db.Books.Add(book); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", book.CategoryID); return(View(book)); }