示例#1
0
        public static void StartATM()
        {
            Console.WriteLine("Please enter your Personal ID Number:");
            int userId = Int32.Parse(Console.ReadLine().Trim());

            Console.WriteLine("PIN:");
            int pin;

            bool auth = false;
            do
            {
                pin = Int32.Parse(Console.ReadLine().Trim());
              
                if (!authService.AuthenticateUser(userId, pin))
                {
                    Console.WriteLine("Either your ID or PIN is incorrect. Try again.");
                    Thread.Sleep(1000);
                    StartATM();
                }
                else
                {
                    auth = true;
                }
            } while (!auth);

            var ah = accountHolderService.GetAccountHolder(userId);

            Console.WriteLine($"Welcome back, {ah.FirstName}. Which account would you like to access? Account ID:");
            int id;

            Account account;
            bool loggedIn = false;

            do
            {
                id = Int32.Parse(Console.ReadLine().Trim());
                account = AccountById(id);

                if (account != null)
                {
                    loggedIn = true;
                }
                else
                {
                    Console.WriteLine("No account with that ID.");
                    Thread.Sleep(1000);
                }
            } while (!loggedIn);
  
            do
            {
                Console.WriteLine(@"How may I assist you?
                                   1...................Check Balance
                                   2...................Make a Withdrawal
                                   3...................Make a Deposit
                                   4...................Account Activity
                                   5...................Exit");
                var option = int.Parse(Console.ReadLine().Trim());
                switch (option)
                {
                     case 1:
                         Balance(id);
                         Thread.Sleep(1000);
                         break;
                     case 2:
                         Withdrawal(id);
                         Thread.Sleep(1000);
                         break;

                     case 3:
                         Deposit(id);
                         Thread.Sleep(1000);
                         break;

                     case 4:
                         Activity(id);
                         Thread.Sleep(1000);
                         break;
                     case 5:
                         Console.WriteLine("Thank you. Goodbye");
                         Environment.Exit(0);
                         break;

                     default:
                         Console.WriteLine("Invalid Entry");
                         break;
                }
            } while (loggedIn /*&& auth == true*/);

        }