Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #3
0
 public int AddNewAccount(string username, string password, int accountTypeId)
 {
     DBManager db = new DBManager();
     return db.AddNewAccount(username, password, accountTypeId);
 }
Beispiel #4
0
        public int CheckUpdateAccount(int id, string user, string pass, int a_type)
        {
            DBManager db = new DBManager();
            int contactCount = db.GetContactCountByAccountId(id);

            if (contactCount == 0)
            {
                AccountDB acc = db.GetAccountByUserNameAndAccountTypeId(user, a_type);
                int accId = acc.Id;
                accId = accId > 0 ? accId : id;

                return (db.UpdateAccountById(accId, user, pass, a_type) > 0 ? accId : -1);
            }
            else
            {
                AccountD account = db.GetAccountById(id);
                if (account.UserName.Equals(user) && account.AccountTypeId == a_type)
                {
                    return (db.UpdateAccountById(id, user, pass, a_type) > 0 ? id : -1);
                }
                else
                {
                    AccountDB acc = db.GetAccountByUserNameAndAccountTypeId(user, a_type);
                    int accId = acc.Id;
                    if (accId > 0)
                    {
                        return (db.UpdateAccountById(accId, user, pass, a_type) > 0 ? accId : -1);
                    }
                    else
                    {
                        return db.AddNewAccount(user, pass, a_type);
                    }
                }
            }
        }