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); } }
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; } }