public ActionResult Edit(Product product) { if (ModelState.IsValid) { db.Products.Attach(product); db.ObjectStateManager.ChangeObjectState(product, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Categories, "id", "Name", product.CategoryID); return View(product); }
public ActionResult Create(Product product) { if (ModelState.IsValid) { db.Products.AddObject(product); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Categories, "id", "Name", product.CategoryID); return View(product); }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
/// <summary> /// Create a new Product object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="backgroundImagePath">Initial value of the BackgroundImagePath property.</param> public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String backgroundImagePath) { Product product = new Product(); product.id = id; product.Name = name; product.BackgroundImagePath = backgroundImagePath; return product; }