예제 #1
0
        // Account

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

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

                account = db.GetAccountById(accountID);             
            }
            account.HostType = hostType;
            return account;
        }
예제 #2
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;
        }