Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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);
     }
 }