public bool Update(City entity, bool autoSave = true) { try { db.Cities.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; if (autoSave) { return(Convert.ToBoolean(db.SaveChanges())); } else { return(false); } } catch { return(false); } }
public bool Update(Product entity, string imagePath, bool autoSave = true) { try { if (imagePath != null) { entity.Image = imagePath; } db.Products.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; if (autoSave) { return(Convert.ToBoolean(db.SaveChanges())); } else { return(false); } } catch { return(false); } }