示例#1
0
        public User ActivateUser(string username, string activationid)
        {
            User user;

            using (ExternalDbContext db = new ExternalDbContext())
            {
                user = db.Users.FirstOrDefault(x => x.username == username);
                user.usergroupid = 2;
                db.Users.Attach(user);
                db.Entry(user).Property(u => u.usergroupid).IsModified = true;
                db.SaveChanges();
            }

            if (user != null)
            {
                using (ExternalDbContext db = new ExternalDbContext())
                {
                    db.Database.ExecuteSqlCommand("DELETE FROM `vb3_useractivation` WHERE userid = @userid AND activationid = @activationid", new MySqlParameter("userid", user.userid), new MySqlParameter("activationid", activationid));
                    db.SaveChanges();
                }
            }

            return user;
        }
示例#2
0
        public void UpdateForumSession(string username, string sessionhash, int loggedin)
        {
            int forumUserId = 0;

            using (NtxfcDbContext db = new NtxfcDbContext())
            {
                Login login = db.Logins.FirstOrDefault(x => x.Username == username);
                if (login != null)
                    forumUserId = login.ForumUserId;
            }

            if (forumUserId != 0)
            {
                using (ExternalDbContext db = new ExternalDbContext())
                {
                    var session = db.Sessions.FirstOrDefault(x => x.sessionhash == sessionhash);
                    if (session != null)
                    {
                        session.loggedin = loggedin;
                        session.userid = forumUserId;
                        db.Sessions.Attach(session);
                        db.Entry(session).Property(u => u.loggedin).IsModified = true;
                        db.Entry(session).Property(u => u.userid).IsModified = true;
                        db.SaveChanges();
                    }
                }
            }
        }