// 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; }
// 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; }