public bool editProduct(Product product) { ProductContext db = new ProductContext(); if(product != null) { db.Entry(product).State = EntityState.Modified; //db.SaveChanges(); bool saveFailed; do { saveFailed = false; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { saveFailed = true; // Update the values of the entity that failed to save from the store ex.Entries.Single().Reload(); } } while (saveFailed); return true; } else { return false; } }
public bool editCategory(Category cat) { var db = new ProductContext(); if(cat != null) { db.Entry(cat).State = EntityState.Modified; db.SaveChanges(); return true; } return false; }