public bool RegisterUser(string username, string password)
        {
            var existingUserAccount = GetUserAccount(username);

            if (!IsUserOnline(existingUserAccount))
            {
                // variable is null if it's not in the database, i.e. not registered
                if (existingUserAccount == null)
                {
                    var uuid = _database.uuid().run(_connection);

                    var newUserAccount = new UserAccount
                    {
                        hash = HashPassword(password),
                        username = username,
                        online_status = (int) Status.Offline,
                        role = (int) Roles.User,
                        id = uuid
                    };

                    Result result = _database.db(DatabaseName)
                        .table(UsersTable)
                        .insert(newUserAccount)
                        .run<Result>(_connection);


                    if (result.Inserted.Equals(1))
                    {
                        //User added
                        return true;
                    }

                    // An error occured during the insertion
                    return false;
                }

                // Username already registered
                return false;
            }
            // User already logged in
            return false;
        }
 // UTILITIES
 public bool IsUserAdmin(UserAccount userAccount)
 {
     return userAccount.role.Equals((int) Roles.Administrator);
 }
 public bool IsUserOnline(UserAccount userAccount)
 {
     return userAccount != null && userAccount.online_status.Equals((int) Status.Online);
 }
        public Result UpdateUserAccount(UserAccount userAccount, object hashmap)
        {
            var result = _database.db(DatabaseName)
                .table(UsersTable)
                .get(userAccount.id)
                .update(hashmap)
                .runResult(_connection);

            return result;
        }