コード例 #1
0
        public static void CashWithdrawal()
        {
            Console.Clear();

            Console.WriteLine("===================");
            Console.WriteLine($"Cash Withdrawal");
            Console.WriteLine("===================");

            Console.WriteLine($"{LoggedCustomer.GetFullName()}, how much money do you want to withdraw?");

            int  ammount         = 0;
            bool isAmmountNumber = int.TryParse(Console.ReadLine(), out ammount);

            if (!isAmmountNumber)
            {
                Console.WriteLine("Invalid ammount...");
                Thread.Sleep(1500);
                CashWithdrawal();
            }

            bool isTransactionSuccessfull = LoggedCustomer.WithdrawFromAccount(ammount);

            if (isTransactionSuccessfull)
            {
                Console.WriteLine($"Please get your money...");
                Thread.Sleep(1500);
                CheckBalance();
            }
            else
            {
                Console.WriteLine($"Sorry, you don't have enough money for the transaction.");
                Thread.Sleep(1500);
                CheckBalance();
            }
        }
コード例 #2
0
        public static void CashTransfer()
        {
            Console.Clear();

            Console.WriteLine("===================");
            Console.WriteLine($"Cash Transfer");
            Console.WriteLine("===================");

            Console.WriteLine($"{LoggedCustomer.GetFullName()}, please enter the card number that you want to transfer money to?");

            string cardNumber         = Console.ReadLine();
            long   formatedCardNumber = FormatCardNumber(cardNumber);

            if (formatedCardNumber == -1)
            {
                Console.WriteLine("Sorry, invalid card number, please try agian...");
                Thread.Sleep(1500);
                CashTransfer();
                return;
            }

            Customer customerForTransfer = ATM_DB.Customers.Where(customer => customer.CardNumber == formatedCardNumber).FirstOrDefault();

            if (customerForTransfer == null)
            {
                Console.WriteLine("Sorry, this credit card number does not exist.");
                Thread.Sleep(1500);
                CashTransfer();
                return;
            }

            Console.WriteLine($"{LoggedCustomer.GetFullName()}, how much money do you want to transfer to {customerForTransfer.GetFullName()}?");

            int  amount          = 0;
            bool isAmmountNumber = int.TryParse(Console.ReadLine(), out amount);

            if (!isAmmountNumber)
            {
                Console.WriteLine("Invalid ammount...");
                Thread.Sleep(1500);
                CashTransfer();
            }

            //if (amount > LoggedUser.GetUserBalance())
            //{
            //    Console.WriteLine("Sorry, you dont have enough money.");
            //    Thread.Sleep(1500);
            //    CashTransfer();
            //}

            bool isWithdrawSuccessfull = LoggedCustomer.WithdrawFromAccount(amount);

            if (!isWithdrawSuccessfull)
            {
                Console.WriteLine("Sorry, you dont have enough money.");
                Thread.Sleep(1500);
                CashTransfer();
            }

            customerForTransfer.DepositMoneyToAccount(amount);
            Console.WriteLine("Transfering money...");
            Thread.Sleep(2000);
            Console.WriteLine($"{LoggedCustomer.GetFullName()}, you have succesfully transfered {amount}$ to {customerForTransfer.GetFullName()}");
            Thread.Sleep(2000);
            CheckBalance();
        }