Exemple #1
0
        private static void ShowAccountMenu(Account account)
        {
            int     choice;
            decimal amount;
            var     showMenu = true;

            while (showMenu)
            {
                Console.WriteLine($"\n***** Account {account.Number} *****");
                Console.WriteLine("1. Check balance");
                Console.WriteLine("2. Withdraw");
                Console.WriteLine("3. Deposit");
                Console.WriteLine("4. Add account owner");
                Console.WriteLine("5. All transactions");
                Console.WriteLine("6. Exit");
                Console.WriteLine("**************************\n");
                Console.WriteLine("Enter your choice: ");

                choice = int.Parse(Console.ReadLine());

                try
                {
                    switch (choice)
                    {
                    case 1:
                        Console.WriteLine($"Your balance is : {account.GetBalance()} ");
                        break;

                    case 2:
                    {
                        Console.WriteLine("enter the amount to withdrow: ");
                        amount = decimal.Parse(Console.ReadLine());
                        account.Withdrawal(amount, DateTime.Now);
                    }
                    break;

                    case 3:
                    {
                        Console.WriteLine("enter the amount to deposit: ");
                        amount = decimal.Parse(Console.ReadLine());
                        account.Deposit(amount, DateTime.Now);
                    }
                    break;

                    case 4:
                    {
                        Console.WriteLine("enter owner id");
                        int ownerId = int.Parse(Console.ReadLine());
                        Console.WriteLine("enter owner first name");
                        string firstName = Console.ReadLine();
                        Console.WriteLine("enter owner last name");
                        string lastName = Console.ReadLine();

                        var owner = new Owner(ownerId, firstName, lastName);
                        account.AddAccountOwner(owner);
                        Console.WriteLine("owner added successfully");
                    } break;

                    case 5:
                    {
                        Console.WriteLine(account.GetAccountTransactions());
                    } break;

                    case 6:
                    {
                        Console.WriteLine("Good bye");
                        showMenu = false;
                    } break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.Write("Enter to continue");
                Console.ReadLine();
            }
        }