Beispiel #1
0
        // Account

        public AccountDB GetOrAddAccountByAccountText(string accountText)
        {
            DBManager db = new DBManager();
            HostType hostType = MyUtils.GetHostTypeFromAccount(accountText);
            string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType);
            AccountDB account = db.GetAccountByUserNameAndAccountTypeName(accountText, accountTypeName);

            if(account.Id <= 0) // add new
            {
                AccountTypeDB type = db.GetAccountTypeByName(accountTypeName);
                int accountID = db.AddNewAccount(accountText, "", type.Id);

                account = db.GetAccountById(accountID);
                account.HostType = hostType;
            }
            account.AccountTypeName = accountTypeName;
            return account;
        }