public ActionResult Create(Product product) { if (ModelState.IsValid) { db.Products.AddObject(product); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ManifactorId = new SelectList(db.Manifactors, "ManifactorId", "Name", product.ManifactorId); return View(product); }
public static void AddProductToUserCart(aspnet_Users user,Product product,int count) { SupermarketEntities db = new SupermarketEntities(); db.AddToUserCarts(new UserCart() { Product=product, aspnet_Users=user, Count = count, }); db.SaveChanges(); }
/// <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="productId">Initial value of the ProductId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="price">Initial value of the Price property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="categoryId">Initial value of the CategoryId property.</param> /// <param name="manifactorId">Initial value of the ManifactorId property.</param> public static Product CreateProduct(global::System.Int32 productId, global::System.String name, global::System.Decimal price, global::System.Single quantity, global::System.Int32 categoryId, global::System.Int32 manifactorId) { Product product = new Product(); product.ProductId = productId; product.Name = name; product.Price = price; product.Quantity = quantity; product.CategoryId = categoryId; product.ManifactorId = manifactorId; return product; }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { db.Products.Attach(product); db.ObjectStateManager.ChangeObjectState(product, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ManifactorId = new SelectList(db.Manifactors, "ManifactorId", "Name", product.ManifactorId); return View(product); }