Beispiel #1
0
        public void Update(string username, User user)
        {
            var parms = new Dictionary<string, string>();
            parms.Add("@TableName", "users");
            parms.Add("@User", "user");
            parms.Add("@UserName", username);

            _db.Update("users", user.ToDictionary(), "@User = '******'", parms);
        }
Beispiel #2
0
        private User NewUser(string username)
        {
            var user = new User(username);
            user.FirstSeen = DateTime.Now;
            var stream = _twitch.GetTwitchStream(Chat.MainChannel.Substring(1));
            if (stream != null) user.FirstGame = stream.game;

            var data = user.ToDictionary();
            data.Add("user", user.Name);
            _db.Insert("users", data);

            return user;
        }
Beispiel #3
0
        private void InitializeUser(string username)
        {
            //Get the message to be edited
            var parms = new Dictionary<string, string>();
            parms.Add("@TableName", "users");
            parms.Add("@User", "user");
            parms.Add("@Name", username);

            var results = _db.Query("SELECT * FROM @TableName WHERE @User = '******'", parms);

            //If user isn't found, create a new user
            if (results.Rows.Count == 0)
                _users[username] = NewUser(username);
            else //Otherwise, create a user and fill it with data from the database.
            {
                var user = new User(username, DataRowToDictionary(results.Rows[0]));
                _users[username] = user;
            }
        }