Esempio n. 1
0
        /// <summary>
        /// Displays the login dialog.
        /// </summary>
        private static void LoginDialog()
        {
            Console.Clear();
            WriteHeader();
            Console.WriteLine("Login\n");

            currentClerk = new BankClerk();

            var iban = PromptForIban();

            if (!iban.HasValue)
            {
                return;
            }

            var loginSuccessful = false;

            while (!loginSuccessful)
            {
                Console.WriteLine("Password: ");
                var password = Console.ReadLine();

                loginSuccessful = currentClerk.Login(iban.Value, password);
            }

            ManagementMenu();
        }
Esempio n. 2
0
        /// <summary>
        /// Displays the Management menu.
        /// </summary>
        /// <exception cref="InvalidOperationException">In case the selected option does not exist</exception>
        private static void ManagementMenu()
        {
            var quit = false;

            while (!quit)
            {
                Console.Clear();
                WriteHeader();
                Console.WriteLine($"Hi {currentClerk.SessionAccount.AccountHolder}! Account: {currentClerk.SessionAccount.AccountName}");
                Console.WriteLine($"Your balance: {currentClerk.SessionAccount.Credit}");

                string[] availableOptions =
                {
                    "Use ATM to put money",
                    "Transfer Money",
                    "Delete this account",
                    "Change Password",
                    "Log out"
                };

                var selection = PromptUser(availableOptions, false);

                switch (selection)
                {
                case 0:
                    ATMDialog();
                    break;

                case 1:
                    TransferMoneyDialog();
                    break;

                case 2:
                    if (DeleteAccountDialog())
                    {
                        currentClerk = null;
                        return;
                    }
                    break;

                case 3:
                    ChangePasswordDialog();
                    break;

                case 4:
                    currentClerk = null;
                    quit         = true;
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Displays the creation dialog.
        /// </summary>
        private static void AccountCreationDialog()
        {
            Console.Clear();
            WriteHeader();

            currentClerk = new BankClerk();

            Console.WriteLine("\nCreate new account:");

            Console.Write("First name: ");
            var firstName = Console.ReadLine();

            Console.Write("Last name: ");
            var lastName = Console.ReadLine();

            DateTime?birthDate = null;

            while (!birthDate.HasValue)
            {
                Console.Write("Birth date: ");

                try
                {
                    birthDate = DateTime.Parse(Console.ReadLine());
                }
                catch (Exception ex) when(ex is FormatException || ex is ArgumentNullException)
                {
                    birthDate = null;
                }
            }

            var accountHolder = new Person(firstName, lastName, birthDate.Value);

            Console.Write("Account name(e.g. use case): ");
            var accountName = Console.ReadLine();

            Console.Write("Please enter a password for your account: ");
            var password = Console.ReadLine();

            var iban = currentClerk.CreateBankAccount(accountHolder, accountName, password, null);

            Console.WriteLine("\n\nAccount has been successfully created! Remember these Credentials:\n");

            Console.WriteLine($"IBAN: {iban}");
            Console.WriteLine($"Password: {password}");

            Console.WriteLine("\nPress enter to continue...");
            Console.ReadKey();
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     currentClerk = new BankClerk();
     MainMenu();
 }