コード例 #1
0
        public string Delete(string[] @params, LogNetClient invokerClient)
        {
            if (@params.Count() == 0)
            {
                return("Invalid arguments. Type 'help account delete' to get help.");
            }

            var account = AccountManager.GetAccountByEmail(@params[0]);

            if (account == null)
            {
                return(string.Format("No account with email '{0}' exists.", @params));
            }

            //Delete game accounts for account
            //which in turn will delete toons for each game account
            foreach (var gameAccount in GameAccountManager.GetGameAccountsForAccount(account))
            {
                GameAccountManager.DeleteGameAccount(gameAccount);
            }

            AccountManager.DeleteAccount(account);

            return(string.Format("Deleted account {0}.", @params));
        }
コード例 #2
0
        public string Add(string[] @params, LogNetClient invokerClient)
        {
            if (@params.Count() < 3)
            {
                return("Invalid arguments. Type 'help account add' to get help.");
            }

            var email         = @params[0];
            var password      = @params[1];
            var battleTagName = @params[2];
            var userLevel     = Account.UserLevels.User;

            if (@params.Count() == 4)
            {
                var level = @params[3].ToLower();
                switch (level)
                {
                case "owner":
                    userLevel = Account.UserLevels.Owner;
                    break;

                case "admin":
                    userLevel = Account.UserLevels.Admin;
                    break;

                case "gm":
                    userLevel = Account.UserLevels.GM;
                    break;

                case "user":
                    userLevel = Account.UserLevels.User;
                    break;

                default:
                    return(level + " is not a valid user level.");
                }
            }

            if (!email.Contains('@'))
            {
                return(string.Format("'{0}' is not a valid email address.", email));
            }

            if (battleTagName.Contains('#'))
            {
                return("BattleTag must not contain '#' or HashCode.");
            }

            if (password.Length < 8 || password.Length > 16)
            {
                return("Password should be a minimum of 8 and a maximum of 16 characters.");
            }

            if (AccountManager.GetAccountByEmail(email) != null)
            {
                return(string.Format("An account already exists for email address {0}.", email));
            }

            var account     = AccountManager.CreateAccount(email, password, battleTagName, userLevel);
            var gameAccount = GameAccountManager.CreateGameAccount(account);

            account.DBAccount.DBGameAccounts.Add(gameAccount.DBGameAccount);
            return(string.Format("Created new account {0} [user-level: {1}] Full BattleTag: {2}.", account.Email, account.UserLevel, account.BattleTag));
        }