示例#1
0
        public int Add(T entity)
        {
            _model.Set <T>().Add(entity);
            int result = _model.SaveChanges();

            return(result);
        }
示例#2
0
        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));
        }
示例#3
0
 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"));
 }