Exemplo n.º 1
0
        private void transferBetweenAccounts(object o)
        {
            if (transferFrom != null && transferTo != null)
            {
                AccountModel account1 = AccountModel.AccountDictionary[transferFrom.Id];
                AccountModel account2 = AccountModel.AccountDictionary[transferTo.Id];
                if (Validator.AccountsShouldNotMatchCheck(account1, account2))
                {
                    if (Validator.ValidDouble(TransferAmount))
                    {
                        {
                            double?newFromAccountBalance;
                            double?newToAccountBalance;
                            AccountModel.TransferBetweenAccounts(account1, account2, TransferAmount,
                                                                 out newFromAccountBalance, out newToAccountBalance);
                            account1.AddTransaction(DateTime.Today, "Transfer to: " + account2.Name, TransferAmount,
                                                    "Transfer");
                            account2.AddTransaction(DateTime.Today, "Transfer from: " + account1.Name, TransferAmount,
                                                    "Transfer");


                            //Update Databinds
                            account1.Balance = newFromAccountBalance;
                            account2.Balance = newToAccountBalance;
                            ColourManager.BalanceColourCheck(account1, account2);
                            TransferFrom = new AccountModel(transferFrom.Id, transferFrom.Name, newFromAccountBalance);
                            TransferTo   = new AccountModel(transferTo.Id, transferTo.Name, newToAccountBalance);
                            refreshAll();
                        }
                    }
                    else
                    {
                        accountSnackbarMessage(4500, "Please enter a valid number.");
                    }
                }
                else
                {
                    accountSnackbarMessage(6000, "You can't transfer to the same account.");
                }
            }
            else
            {
                accountSnackbarMessage(6000, "Please select two accounts to make a transfer between.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create test accounts and transactions.
        /// </summary>
        private void createTestAccounts(object o)
        {
            const int numberOfTestAccounts     = 8;
            const int numberOfTestTransactions = 320;
            const int numberOfDays             = 365;


            for (int i = 0; i < numberOfTestAccounts; i++)
            {
                if (obcAccounts.Count < 1)
                {
                    accountName = "Dit Lexaragez";
                }
                else
                {
                    accountName = RandomGenerator.GetRandomStringFromPath().Remove(8) + " Test";
                }
                accountBalance = 0;

                createAccount(o);

                for (int k = 0; k < numberOfTestTransactions; k++)
                {
                    string randomTransactionType =
                        TransactionModel.TransactionTypes[
                            RandomGenerator.GetRandomIntMaxValue(TransactionModel.TransactionTypes.Count)];
                    int randomTransactionAmount = RandomGenerator.GetRandomIntMaxValue(999);
                    if (randomTransactionType != "Income")
                    {
                        account.Balance -= randomTransactionAmount;
                    }
                    else
                    {
                        randomTransactionAmount *= 9; //Make the Income transactions bigger
                        account.Balance         += randomTransactionAmount;
                    }
                    account.AddTransaction(RandomGenerator.GenerateRandomDate(numberOfDays), "Test transaction " + k,
                                           randomTransactionAmount, randomTransactionType);
                    ColourManager.BalanceColourCheck(account);
                }
                SelectedAccount = account;
            }
        }
Exemplo n.º 3
0
        private void updateBalance(object o)
        {
            if (Validator.ValidDouble(updateBalanceAmount))
            {
                account = AccountModel.AccountDictionary[updateBalanceSelectedAcc.Id];
                AccountModel.UpdateBalance(account, updateBalanceAmount, selectedTransactionType);
                account.AddTransaction(selectedDate, transactionDescription, updateBalanceAmount,
                                       selectedTransactionType);

                UpdateBalanceSelectedAcc = null;
                UpdateBalanceSelectedAcc = account;
                UpdateBalanceAmount      = null;
                refreshAll();
                SelectedAccount = updateBalanceSelectedAcc;
            }
            else
            {
                accountSnackbarMessage(4500, "Please enter a valid number");
            }
        }