/// <summary>
 /// The method where we will choose the correct option to go
 /// </summary>
 public void Show()
 {
     int option;
     const int EXIT = 0, EXPENSE = 1, EXPENSE_TYPE = 2, PAYMENT_METHOD = 3, INCOME_TYPE = 4, INCOME = 5, BALANCE = 6;
     do
     {
         Menu();
         Console.WriteLine("Choose an option.");
         
         if (int.TryParse(Console.ReadLine(), out option))
         {
             switch (option)
             {
                 case EXPENSE:
                     ExpenseUI expUI = new ExpenseUI();
                     expUI.Show();
                     break;
                 case EXPENSE_TYPE:
                     ExpenseTypeUI retUI = new ExpenseTypeUI();
                     retUI.Show();
                     break;
                 case PAYMENT_METHOD:
                     PaymentMethodUI metUI = new PaymentMethodUI();
                     metUI.Show();
                     break;
                 case INCOME_TYPE:
                     IncomeTypeUI incTUI = new IncomeTypeUI();
                     incTUI.Show();
                     break;
                 case INCOME:
                     IncomeUI incUI = new IncomeUI();
                     incUI.Show();
                     break;
                 case BALANCE:
                     BalanceUI balUI = new BalanceUI();
                     balUI.Show();
                     break;
                 case EXIT:
                     Console.WriteLine("Bye! Bye!");
                     break;
                 default:
                     Console.WriteLine("Unknown option\nPlease try again!");
                     break;
             }
         }
         else
         {
             option = 999;
         }
     } while (option != 0);
 }
Esempio n. 2
0
        /// <summary>
        /// The method that will choose a income type in the repository
        /// </summary>
        /// <returns>A income type</returns>
        private IncomeType GetIncomeType()
        {
            IncomeType type = null;
            IncomeController ic = new IncomeController();
            IncomeTypeUI itUI = new IncomeTypeUI();

            int numIncType = ic.GetIncomeTypeRepositorySize();
            if (numIncType == 0)
            {
                Console.WriteLine("Create a new Income Type");
                itUI.ShowRegisterIncomeType();
                type = ic.GetLastExpenseType();
            }
            else
            {
                int option = 999;
                Console.WriteLine("Choose an Income Type");
                itUI.List();

                do
                {
                    if (int.TryParse(Console.ReadLine(), out option))
                    {
                        type = ic.GetIncomeType(option);
                    }
                    else
                    {
                        option = -1;
                    }
                } while (option < 0 || option > numIncType);
            }

            return type;
        }