BlottoBeats.Server.Database.createUser C# (CSharp) Method

createUser() private method

private createUser ( string username, string hash ) : bool
username string
hash string
return bool
        private bool createUser(string username, string hash)
        {
            // The token expiry date and string should both start null

            // This function should check to see if the username is already in use.
            // If so, it should not create a new entry in the table, and the function should return false.
            // If the username is not already in use, it should create a new entry in the user table and return true.
            MySqlConnection conn = new MySqlConnection(connString);
            MySqlCommand command = conn.CreateCommand();

            if (GetID(username) == 0)
            {
                int nextId = GetNextAvailableID("users");
                string token = null;
                String date = "1000-01-01 00:00:00";
                SQLNonQuery(conn, "Insert into users (idusers,username,passwordHash,tokenExpire,tokenStr) values('" + nextId + "','" + username + "','" + hash + "','" + date + "','" + token + "')");
                createUserTable(nextId);
                return true;
            }

            return false;
        }