private static void Deposit(User loggedUser)
        {
            TransactionType transaction     = TransactionType.Deposit;
            decimal         depositedAmount = CheckAmount(transaction);
            DateTime        transactionDate = DateTime.Now;

            string question = "Do you want to deposit to another account? y/n: ";
            string answer   = ValidateAnswer(question);

            User accountHolder = new User();

            if (answer == "y")
            {
                accountHolder = GetAccountHolder(accountHolder);
            }
            else
            {
                accountHolder = loggedUser;
            }

            DepositQuery(accountHolder, depositedAmount, transactionDate);

            InternalBankAccounts transactionHolder = new InternalBankAccounts(accountHolder.Username, loggedUser.Username, depositedAmount, transactionDate, transaction);

            Console.WriteLine(transactionHolder);

            ConfirmTransaction(transactionHolder);
            ViewMyAccount(loggedUser);
        }
Beispiel #2
0
        protected static void ConfirmTransaction(InternalBankAccounts transactionHolder)
        {
            string question = "Confirm transaction? y/n: ";
            string answer   = ApplicationMenus.ValidateAnswer(question);

            if (answer == "y")
            {
                FileAccess.memoryBuffer.Add(transactionHolder);

                try
                {
                    afdempDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        private static void Withdraw(User loggedUser)
        {
            DateTime transactionDate = DateTime.Now;
            decimal  DBAmount        = 0;
            User     accountHolder   = new User();

            TransactionType transaction    = TransactionType.Withdraw;
            decimal         withdrawAmount = CheckAmount(transaction);

            string question = "Do you want to withdraw from another account? y/n: ";
            string answer   = ValidateAnswer(question);

            if (answer == "y")
            {
                accountHolder = GetAccountHolder(accountHolder);

                DBAmount = GetAmountFromDB(accountHolder);
            }
            else
            {
                accountHolder = loggedUser;

                DBAmount = loggedUser.Balance;
            }

            if (withdrawAmount <= DBAmount)
            {
                WithdrawQuery(accountHolder, withdrawAmount, transactionDate);

                InternalBankAccounts transactionHolder = new InternalBankAccounts(loggedUser.Username, accountHolder.Username, withdrawAmount, transactionDate, transaction);
                Console.WriteLine(transactionHolder);

                ConfirmTransaction(transactionHolder);
                ViewMyAccount(loggedUser);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Not Enough Balance");
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
        private static void Transfer(User loggedUser)
        {
            TransactionType transaction     = TransactionType.Transfer;
            decimal         transferAmount  = CheckAmount(transaction);
            DateTime        transactionDate = DateTime.Now;

            User accountHolder = new User();

            accountHolder = GetAccountHolder(accountHolder);

            if (loggedUser.ID == accountHolder.ID)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("You cannot transfer money to your account");
                Console.ForegroundColor = ConsoleColor.Gray;
            }
            else
            {
                if (transferAmount <= loggedUser.Balance)
                {
                    TransferQuery(loggedUser, accountHolder, transferAmount, transactionDate);

                    InternalBankAccounts transactionHolder = new InternalBankAccounts(accountHolder.Username, loggedUser.Username, transferAmount, transactionDate, transaction);
                    Console.WriteLine(transactionHolder);

                    ConfirmTransaction(transactionHolder);
                    ViewMyAccount(loggedUser);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Not Enough Balance");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }
        }