Ejemplo 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.");
            }
        }