コード例 #1
0
 public bool Update(UnionManager.Models.DomainModels.Trade entity, out string message, bool autoSave = true)
 {
     try
     {
         UnionManager.Models.DomainModels.Trade trade = Find(entity.Id);
         db.Entry(trade).State = System.Data.Entity.EntityState.Detached;
         db.Trades.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 Update(UnionManager.Models.DomainModels.User entity, string fileName, string oldImage, out string message, bool autoSave = true)
        {
            try
            {
                if (fileName != null)
                {
                    entity.Image = fileName;
                }
                else
                if (oldImage != null)
                {
                    entity.Image = oldImage;
                }

                UnionManager.Models.DomainModels.User user = Find(entity.Id);
                db.Entry(user).State = System.Data.Entity.EntityState.Detached;
                db.Users.Attach(entity);
                db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                if (autoSave)
                {
                    message = "";
                    return(Convert.ToBoolean(db.SaveChanges()));
                }
                else
                {
                    message = "";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                message = ex.GetBaseException().Message;
                return(false);
            }
        }
コード例 #3
0
 public bool Update(UnionManager.Models.DomainModels.Role entity, bool autoSave = true)
 {
     try
     {
         UnionManager.Models.DomainModels.Role role = Find(entity.Id);
         db.Entry(role).State = System.Data.Entity.EntityState.Detached;
         db.Roles.Attach(entity);
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         if (autoSave)
         {
             bool result = Convert.ToBoolean(db.SaveChanges());
             return(result);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }