Пример #1
0
 public bool Update(UnionManager.Models.DomainModels.Color entity, out string message, bool autoSave = true)
 {
     try
     {
         UnionManager.Models.DomainModels.Color color = Find(entity.Id);
         db.Entry(color).State = System.Data.Entity.EntityState.Detached;
         db.Colors.Attach(entity);
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         if (autoSave)
         {
             bool result = Convert.ToBoolean(db.SaveChanges());
             message = "";
             return(result);
         }
         else
         {
             message = "";
             return(false);
         }
     }
     catch (Exception ex)
     {
         message = ex.GetBaseException().Message;
         return(false);
     }
 }
Пример #2
0
 public bool Add(UnionManager.Models.DomainModels.Color entity, out string message, bool autoSave = true)
 {
     try
     {
         db.Colors.Add(entity);
         if (autoSave)
         {
             bool result = Convert.ToBoolean(db.SaveChanges());
             message = "";
             return(result);
         }
         else
         {
             message = "";
             return(false);
         }
     }
     catch (Exception ex)
     {
         message = ex.GetBaseException().Message;
         return(false);
     }
 }