/// <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); }
/// <summary> /// The method that will choose a expense type in the repository /// </summary> /// <returns>A expense type</returns> private ExpenseType GetExpenseType() { ExpenseType type = null; ExpenseController ec = new ExpenseController(); ExpenseTypeUI etUI = new ExpenseTypeUI(); int numExpType = ec.GetExpenseTypeRepositorySize(); if (numExpType == 0) { Console.WriteLine("Create a new Expense Type"); etUI.ShowRegisterExpenseType(); type = ec.GetLastExpenseType(); } else { int option = 999; Console.WriteLine("Choose a Expense Type"); etUI.List(); do { if (int.TryParse(Console.ReadLine(), out option)) { type = ec.GetExpenseType(option); } else { option = -1; } } while (option < 0 || option > numExpType); } return type; }