Esempio n. 1
0
 public bool UpdateProduct(Product product)
 {
     try
     {
         Product existing = contextDB.Products.Find(product.ProductId);
         ((IObjectContextAdapter)contextDB).ObjectContext.Detach(existing);
         contextDB.Entry(product).State = EntityState.Modified;
         contextDB.SaveChanges();
         return(true);
     }
     catch { return(false); }
 }
Esempio n. 2
0
 public bool UpdateCategory(Category category)
 {
     try
     {
         Category existing = contextDB.Categories.Find(category.CategoryId);
         ((IObjectContextAdapter)contextDB).ObjectContext.Detach(existing);
         contextDB.Entry(category).State = EntityState.Modified;
         contextDB.SaveChanges();
         return true;
     }
     catch { return false; }
 }