private async Task ExecuteMenuSelection(RecipeMenuOption option) { switch (option) { case RecipeMenuOption.InValid: _logger.LogWarning("Attempted to execute invalid menu selection"); break; case RecipeMenuOption.NewRecipe: Console.WriteLine(); await NewRecipe(); break; case RecipeMenuOption.LookUpRecipe: Console.WriteLine(); await LookupRecipe(); break; case RecipeMenuOption.ShowRecipe: Console.WriteLine(); await ListRecipe(); break; case RecipeMenuOption.DeleteRecipe: Console.WriteLine(); await DeleteRecipe(); break; case RecipeMenuOption.UpdateRecipe: Console.WriteLine(); UpdateRecipe(); break; case RecipeMenuOption.GoBack: Console.WriteLine(); break; default: break; } }
public async Task Show() { ConsoleHelper.DefaultColor = ConsoleColor.Blue; ConsoleHelper.ColorWriteLine(ConsoleColor.Yellow, "Recipe Menu"); Console.WriteLine(); ConsoleHelper.ColorWriteLine("1.) New Recipe"); ConsoleHelper.ColorWriteLine("2.) Lookup Recipe"); ConsoleHelper.ColorWriteLine("3.) Show Recipe List"); ConsoleHelper.ColorWriteLine("4.) Delete Recipe"); ConsoleHelper.ColorWriteLine("5.) Update Recipe"); Console.WriteLine(); ConsoleHelper.ColorWriteLine(ConsoleColor.Red, "6.) Back to Main Menu"); Console.WriteLine(); string input = string.Empty; int option = 0; bool valid = false; while (!valid) { ConsoleHelper.ColorWrite(ConsoleColor.Yellow, "Please select an option: "); input = Console.ReadLine(); valid = ConsoleHelper.ValidateInt(input, (int)RecipeMenuOption.NewRecipe, (int)RecipeMenuOption.GoBack, out option); if (!Enum.IsDefined(typeof(RecipeMenuOption), option)) { _logger.LogWarning("Option is not in enum"); valid = false; } } RecipeMenuOption choice = (RecipeMenuOption)option; await ExecuteMenuSelection(choice); }