// Display Item Found Success public void DisplayItemFound(string itemInformation) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(this.GetItemHeader()); Console.ForegroundColor = ConsoleColor.Gray; _beverageRepository.FindById(itemInformation); }
static void Main(string[] args) { // Set Console Window Size Console.BufferHeight = Int16.MaxValue - 1; Console.WindowHeight = 40; Console.WindowWidth = 120; // Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); // Create an instance of the BeverageCollection class BeverageRepository beverageRepository = new BeverageRepository(); // Display the Welcome Message to the user userInterface.DisplayWelcomeGreeting(); // Display the Menu and get the response. Store the response in the choice integer // This is the 'primer' run of displaying and getting. int choice = userInterface.DisplayMenuAndGetResponse(); // While the choice is not exit program while (choice != 6) { switch (choice) { case 1: // PRINT THE ENTIRE LIST OF BEVERAGES // Heading userInterface.DisplayPrintListHeading(); // Call method to print the list beverageRepository.PrintList(); break; case 2: // SEARCH FOR BEVERAGE BY ID string searchQuery = userInterface.GetSearchQuery(); // Finds beverage and sets it to a string to test string itemInformation = beverageRepository.FindById(searchQuery); // Tests if it was found or not if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } break; case 3: // ADD A NEW BEVERAGE TO THE DATABASE // Create a new instance of Beverage Beverage newBeverageToAdd = new Beverage(); // Gathers information for the beverage newBeverageToAdd.id = userInterface.GetNewIDInformation(); newBeverageToAdd.name = userInterface.GetNewNameInformation(); newBeverageToAdd.pack = userInterface.GetNewPackInformation(); newBeverageToAdd.price = userInterface.GetNewPriceInformation(); newBeverageToAdd.active = userInterface.GetNewActiveInformation(); // Calls method and passes in the new beverage information beverageRepository.AddNewBeverage(newBeverageToAdd.id, newBeverageToAdd.name, newBeverageToAdd.pack, newBeverageToAdd.price, newBeverageToAdd.active, newBeverageToAdd); break; case 4: // UPDATE THE BEVERAGE THAT WAS JUST ADDED string value = userInterface.GetUpdateBeverageInformation(); // Calls method to update passing in the value of the previous method called beverageRepository.UpdateBeverage(value); break; case 5: // DELETE A BEVERAGE // User picks what droid to delete string deletedValue = userInterface.GetDeleteBeverageInformation(); // Deletes beverage by calling method beverageRepository.DeleteBeverage(deletedValue); break; } // Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { // Set Console Window Size Console.BufferHeight = Int16.MaxValue - 1; Console.WindowHeight = 40; Console.WindowWidth = 120; // Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); // Create an instance of the BeverageRepository class BeverageRepository beverageRepository = new BeverageRepository(); // Display the Welcome Message to the user userInterface.DisplayWelcomeGreeting(); // Display the Menu and get the response. Store the response in the choice integer // This is the 'primer' run of displaying and getting. int choice = userInterface.DisplayMenuAndGetResponse(); // While the choice is not exit program while (choice != 6) { switch (choice) { case 1: // Print Entire List Of Items userInterface.DisplayAllItems(); break; case 2: // Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = beverageRepository.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 3: // Add A New Item To The List string[] newItemInformation = userInterface.GetNewItemInformation(); if (beverageRepository.FindById(newItemInformation[0]) == null) { beverageRepository.AddNewItem( newItemInformation[0], newItemInformation[1], newItemInformation[2], decimal.Parse(newItemInformation[3]), (newItemInformation[4] == "True") ); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; case 4: // Update an item from the list string[] updateItemInformation = userInterface.UpdateItemInformation(); if (beverageRepository.FindById(updateItemInformation[0]) != null) { beverageRepository.UpdateItem( updateItemInformation[0], updateItemInformation[1], updateItemInformation[2], decimal.Parse(updateItemInformation[3]), (updateItemInformation[4] == "True") ); userInterface.DisplayUpdateItemSuccess(); } else { userInterface.DisplayItemFoundError(); } break; case 5: // Delete an item from the list userInterface.DisplayDeleteItem(); string input = Console.ReadLine(); if (beverageRepository.FindById(input) != null) { beverageRepository.DeleteItem(input); userInterface.DisplayDeleteItemSuccess(); } else { userInterface.DisplayItemFoundError(); } break; } // Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }