public int Add(T entity) { _model.Set <T>().Add(entity); int result = _model.SaveChanges(); return(result); }
public ActionResult Create([Bind(Include = "ProductID,Quantity,ReorderLevel")] ProductHolding productHoldings) { if (ModelState.IsValid) { db.ProductHoldings.Add(productHoldings); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productHoldings)); }
public ActionResult EditList(IEnumerable <Product> products) { using (var transatction = db.Database.BeginTransaction(System.Data.IsolationLevel.Serializable)) { foreach (var p in products) { System.Diagnostics.Debug.WriteLine(p.ProductID + "," + p.Quantity); db.Products.Find(p.ProductID).Quantity = p.Quantity; Thread.Sleep(1000 * 30); } System.Diagnostics.Debug.WriteLine("SaveChagne()"); db.SaveChanges(); System.Diagnostics.Debug.WriteLine("commit()"); transatction.Commit(); } return(Redirect("EditList")); }