コード例 #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 CashDeposit()
        {
            Console.Clear();

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

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

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

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

            bool isTransactionSuccessfull = LoggedCustomer.DepositMoneyToAccount(ammount);

            if (isTransactionSuccessfull)
            {
                Console.WriteLine($"Please deposit your money...");
                Thread.Sleep(1500);
                CheckBalance();
            }
            else
            {
                Console.WriteLine($"Sorry, invalid ammount...");
                Thread.Sleep(1500);
                CheckBalance();
            }
        }
コード例 #3
0
        public static void CheckBalance()
        {
            Console.Clear();

            Console.WriteLine("===================");
            Console.WriteLine($"{LoggedCustomer.GetFullName()}, your currnet blance is {LoggedCustomer.GetUserBalance()}");
            Console.WriteLine("===================");
        }
コード例 #4
0
        public static int InitiateAtmUi()
        {
            Console.Clear();

            Console.WriteLine("===================");

            if (LoggedCustomer != null)
            {
                Console.WriteLine($"Welcome {LoggedCustomer.GetFullName()}");

                Console.WriteLine("1) Check Balance");
                Console.WriteLine("2) Cash Withdrawal");
                Console.WriteLine("3) Cash Deposit");
                Console.WriteLine("4) Cash Transfer");
                Console.WriteLine("5) Logout");
            }

            if (LoggedAdmin != null)
            {
                Console.WriteLine($"Welcome {LoggedAdmin.GetFullName()}");

                Console.WriteLine("1) Add money to customer");
                Console.WriteLine("2) Check login sessions");
                Console.WriteLine("3) Logout");
            }

            Console.WriteLine("===================");


            int  choice         = 0;
            bool isChoiceNumber = int.TryParse(Console.ReadLine(), out choice);

            if (!isChoiceNumber)
            {
                Console.WriteLine("Input needs to be a number, please try agian...");
                Thread.Sleep(1500);
                InitiateAtmUi();
                return(-1);
            }

            //int endMenuOption;

            //if (LoggedCustomer != null)
            //{
            //    endMenuOption = 5;
            //}
            //else
            //{
            //    endMenuOption = 3;
            //}

            var endMenuOption = LoggedCustomer != null ? 5 : 3;

            if (choice < 1 || choice > endMenuOption)
            {
                Console.WriteLine("Input is not valid, please try agian...");
                Thread.Sleep(1500);
                InitiateAtmUi();
                return(-1);
            }

            return(choice);
        }
コード例 #5
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();
        }