private static void Main() { // initial loading drinks list from file var loader = new DrinkLoader(); var drinksListGlobal = loader.InitializeDrinksFromFile(); var exitProgram = false; do { var menu = new Menu(); menu.Show(); var choice = menu.GetUserChoice(); switch (choice) { case MenuChoice.FindByName: SearchDrinkConsoleUi.StartSearch(drinksListGlobal, SearchCriterion.Name); break; case MenuChoice.FindByAlcoholContent: SearchDrinkConsoleUi.HandleSearchDrinksByContentInConsole(drinksListGlobal); break; case MenuChoice.FindByIngredient: SearchDrinkConsoleUi.StartSearch(drinksListGlobal, SearchCriterion.Ingredients); break; case MenuChoice.ShowReviewedDrinksList: SearchDrinkConsoleUi.ShowReviewedDrinksHandler(drinksListGlobal); break; case MenuChoice.AddCustomDrink: SearchDrinkConsoleUi.StartCustomDrinkCreation(drinksListGlobal); break; case MenuChoice.UpdateDrinksFromFile: SearchDrinkConsoleUi.AddMoreDrinksFromFile(drinksListGlobal); break; case MenuChoice.DisplayFavourites: FavouritesService.Display(); break; case MenuChoice.Exit: exitProgram = true; break; default: throw new ArgumentOutOfRangeException(); } } while (exitProgram == false); }
public static void DisplayProductDetailsOptions(Drink drink) { while (true) { Console.WriteLine(); if (!drink.IsReviewed) { Console.WriteLine("Press R to leave a review for this drink."); } else if (ValidateReviewAge(drink.DrinkReview.ReviewDate)) { Console.WriteLine("Press R to edit review for this drink."); } Console.WriteLine("Press F to add to favorites list."); Console.WriteLine("Press E to edit drink details."); Console.WriteLine("\nPress ESC to go back."); var userChoice = Console.ReadKey(true); switch (userChoice.Key) { case ConsoleKey.R: if (!drink.IsReviewed || (drink.IsReviewed && ValidateReviewAge(drink.DrinkReview.ReviewDate))) { ReviewUi.GetDataFromUserForNewReview(drink); break; } else { Console.WriteLine("\nUnsupported input, try again...\n"); continue; } case ConsoleKey.F: // Add to favorites method call FavouritesService.AddDrink(drink); break; case ConsoleKey.E: EditDrinkConsoleUi.StartEdition(drink); break; case ConsoleKey.Escape: return; default: Console.WriteLine("\nUnsupported input, try again...\n"); continue; } } }