public static int ChangeUserStatus(string taskId, int userId, UserStatus status)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);

            if (accountCheck < 0)
            {
                return(accountCheck);
            }

            int result = 0;

            // get user details
            UserInfo user = GetUserInternally(userId);

            // place log record
            TaskManager.StartTask(taskId, "USER", "CHANGE_STATUS", user.Username, user.UserId);

            // update user packages
            List <PackageInfo> packages = new List <PackageInfo>();

            // Add the users package(s)
            packages.AddRange(PackageController.GetPackages(userId));

            try
            {
                // change this account
                result = ChangeUserStatusInternal(userId, status);
                if (result < 0)
                {
                    return(result);
                }

                // change peer accounts
                List <UserInfo> peers = GetUserPeers(userId);
                foreach (UserInfo peer in peers)
                {
                    result = ChangeUserStatusInternal(peer.UserId, status);
                    if (result < 0)
                    {
                        return(result);
                    }
                }

                // change child accounts
                List <UserInfo> children = GetUsers(userId, true);
                foreach (UserInfo child in children)
                {
                    // Add the child users packages
                    packages.AddRange(PackageController.GetPackages(child.UserId));

                    // change child user peers
                    List <UserInfo> childPeers = GetUserPeers(child.UserId);
                    foreach (UserInfo peer in childPeers)
                    {
                        result = ChangeUserStatusInternal(peer.UserId, status);
                        if (result < 0)
                        {
                            return(result);
                        }
                    }

                    // change child account
                    result = ChangeUserStatusInternal(child.UserId, status);
                    if (result < 0)
                    {
                        return(result);
                    }
                }

                PackageStatus packageStatus = PackageStatus.Active;
                switch (status)
                {
                case UserStatus.Active: packageStatus = PackageStatus.Active; break;

                case UserStatus.Cancelled: packageStatus = PackageStatus.Cancelled; break;

                case UserStatus.Pending: packageStatus = PackageStatus.New; break;

                case UserStatus.Suspended: packageStatus = PackageStatus.Suspended; break;
                }

                // change packages state
                result = PackageController.ChangePackagesStatus(packages, packageStatus, true);
                if (result < 0)
                {
                    return(result);
                }

                return(0);
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }