Example #1
0
        /// <summary>
        /// Update user
        /// </summary>
        /// <param name="userInfo">userInfo object</param>
        /// <returns>Number of rows are effected</returns>
        public static int Update(tblUser userInfo)
        {
            // Encode password & username
            userInfo.Password = Common.Encode(userInfo.Password);

            var db       = new dbTrainEntities(ConnectionController.GetConnection());
            var usrOrgin = db.tblUsers.Where(g => g.UserID == userInfo.UserID).FirstOrDefault();

            if (usrOrgin == null)
            {
                return(-1);
            }
            db.Attach(usrOrgin);
            db.ApplyPropertyChanges("tblUsers", userInfo);
            return(db.SaveChanges());
        }
Example #2
0
        public static int Update(tblGroup group)
        {
            var db         = new dbTrainEntities(ConnectionController.GetConnection());
            var groupOrgin = db.tblGroups.Where(g => g.GroupID == group.GroupID).FirstOrDefault();

            if (groupOrgin == null)
            {
                return(-1);
            }
            db.Attach(groupOrgin);
            db.ApplyPropertyChanges("tblGroups", group);
            int re = db.SaveChanges();

            db.Connection.Close();
            return(re);
        }
Example #3
0
        public static int Update(tblTrain train)
        {
            var db = new dbTrainEntities(ConnectionController.GetConnection());

            train.ModifiedDate = CommonFactory.GetCurrentDate();
            var originTrain = db.tblTrains.Where(g => g.TrainID == train.TrainID).FirstOrDefault();

            if (originTrain == null)
            {
                return(-1);
            }
            db.Attach(originTrain);
            db.ApplyPropertyChanges("tblTrains", train);

            return(db.SaveChanges());
        }