Exemplo n.º 1
0
        /// <summary>
        /// Realised choosing of services interface
        /// </summary>
        /// <param name="choose"></param>
        public void ServiceSwitch(int choose)
        {
            switch (choose)
            {
            case 1:     //Input money
                while (true)
                {
                    try
                    {
                        Console.Write("Input amount of replenishment: $");
                        Sum     = double.Parse(Console.ReadLine());
                        account = events.InputMoney(Sum, account.Id);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid format, try again!");
                        continue;
                    }
                    break;
                }
                break;

            case 2:     // Output money
                while (true)
                {
                    try
                    {
                        Console.Write("Input the output amount: $");
                        Sum     = double.Parse(Console.ReadLine());
                        account = events.OutputMoney(Sum, account.Id);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid format, try again!");
                        continue;
                    }
                    catch (IndexOutOfRangeException)
                    {
                        Console.WriteLine("Account wasn't found!");
                        continue;
                    }
                    break;
                }
                break;

            case 3:    // TODO deletig feature
                while (true)
                {
                    try
                    {
                        events.DeleteAccount(account.Id);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid format, try again!");
                        continue;
                    }
                    catch (IndexOutOfRangeException)
                    {
                        Console.WriteLine("Account wasn't found!");
                        continue;
                    }
                    break;
                }
                break;

            case 4:     // Find account and show account info
                while (true)
                {
                    try
                    {
                        account = events.FindAccount(account.Id, account.Password);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid format, try again!");
                        continue;
                    }
                    catch (IndexOutOfRangeException)
                    {
                        Console.WriteLine("Account wasn't found!");
                        continue;
                    }
                    break;
                }
                break;

            case 5:     // Close app
                events.EndSession();
                break;

            case 6:     // Create account
                while (true)
                {
                    try
                    {
                        events.OpenAccount();
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Invalid format, try again!");
                        continue;
                    }
                    break;
                }
                break;

            case 7:     //Sing in
                while (true)
                {
                    try
                    {
                        Console.Write("Input account id: ");
                        int id = int.Parse(Console.ReadLine());
                        Console.Write("Input your password: "******"Invalid format, try again!\n");
                        continue;
                    }
                    break;
                }
                break;
            }
        }