public ActionResult Create(Product product) { if (ModelState.IsValid) { db.Product.Add(product); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Category, "CategoryID", "CategoryType", product.CategoryID); ViewBag.MakerID = new SelectList(db.Manufacturer, "MakerID", "Maker", product.MakerID); return View(product); }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Category, "CategoryID", "CategoryType", product.CategoryID); ViewBag.MakerID = new SelectList(db.Manufacturer, "MakerID", "Maker", product.MakerID); return View(product); }