Esempio n. 1
0
        public static void Withdraw()
        {
            Console.WriteLine("Please enter your unique user Pin:");
            string pin       = Console.ReadLine();
            int    pinNumber = UI.CheckPin(pin);

            Console.Clear();
            CheckForCustomer();
            AccountManager accountManager = new AccountManager();

            accountManager.ListOfAccountsByCustomerPin(pinNumber);
            Customer customer = accountManager.GetCustomer(pinNumber);

            accountManager.CheckForNoAccounts(customer);
            Console.WriteLine("Please type in the account ID for which you'd like to make a withdrawal");
            var     answer    = Console.ReadLine();
            int     answerNum = CheckAccountNumber(answer);
            Account acc       = customer.listOfAccounts.FirstOrDefault(a => a.AccountID == answerNum);

            CheckAccountNumber(acc);
            Console.Write("Please enter the amount you would like to withdraw from Account: {0} \n$", acc.AccountID);
            var     stringOutput = Console.ReadLine();
            decimal output       = TryWithdraw(stringOutput);

            acc.MakeWithdrawal(output, DateTime.Now);
            Program.ExecuteUserInput();
        }
 public void Transfer(Account account1, Account account2, decimal withdrawalAmount)
 {
     _amount = withdrawalAmount;
     if (account1.AccountType == "Certificate Deposit" && account1.WithdrawalAmount != account1.Balance)
     {
         account1.MakeWithdrawal(_amount, DateTime.Now);
     }
     else if (account1.AccountType == "Loan")
     {
         Console.WriteLine("Cannot make a transfer from accounts of type loan!");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         account1.MakeWithdrawal(_amount, DateTime.Now);
         account2.MakeDeposit(withdrawalAmount, DateTime.Now);
         Console.WriteLine("Transfer succeeded!");
     }
 }