static void Main(string[] args) { //Set a constant for the size of the collection const int wineItemCollectionSize = 4000; //Set a constant for the path to the CSV File const string pathToCSVFile = "../../../datafiles/winelist.csv"; //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class WineItemCollection wineItemCollection = new WineItemCollection(wineItemCollectionSize); //Create an instance of the CSVProcessor class CSVProcessor csvProcessor = new CSVProcessor(); //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 (choice != 5) { switch (choice) { case 1: //Load the CSV File bool success = csvProcessor.ImportCSV(wineItemCollection, pathToCSVFile); if (success) { //Display Success Message userInterface.DisplayImportSuccess(); } else { //Display Fail Message userInterface.DisplayImportError(); } break; case 2: //Print Entire List Of Items string[] allItems = wineItemCollection.GetPrintStringsForAllItems(); if (allItems.Length > 0) { //Display all of the items userInterface.DisplayAllItems(allItems); } else { //Display error message for all items userInterface.DisplayAllItemsError(); } break; case 3: //Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 4: //Add A New Item To The List string[] newItemInformation = userInterface.GetNewItemInformation(); if (wineItemCollection.FindById(newItemInformation[0]) == null) { wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2]); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { //Set a constant for the size of the collection //const int wineItemCollectionSize = 4000; //Create an Instance of the Database BeveragePBathEntities beveregeEntity = new BeveragePBathEntities(); //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class IWineCollection wineItemCollection = new WineItemCollection(); //Create an instance of the CSVProcessor class //CSVProcessor csvProcessor = new CSVProcessor(); //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 (choice != 6) { switch (choice) { case 1: // Print All foreach (Beverage bev in beveregeEntity.Beverages) { Console.WriteLine("Printing all in the Database! \n"); Console.WriteLine("The ID is: " + bev.id); Console.WriteLine("The Name is: " + bev.name); Console.WriteLine("The Pack is: " + bev.pack); Console.WriteLine("The Price is: " + bev.price); } break; case 2: //Search for a specific ID string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.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 (wineItemCollection.FindById(newItemInformation[0]) == null) { wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2], Convert.ToDecimal(newItemInformation[3])); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; case 4: // Modify Item string[] modifyItem = userInterface.GetInfoToUpdate(); if (wineItemCollection.FindById(modifyItem[0]).Equals(true)) { wineItemCollection.Update(modifyItem[0], modifyItem[1], modifyItem[2], Convert.ToDecimal(modifyItem[3])); } else { userInterface.DisplayItemFoundError(); } break; case 5: //Delete a Wine item by ID string deleteItem = userInterface.GetIDToDelete(); if (wineItemCollection.FindById(deleteItem).Equals(true)) { wineItemCollection.Delete(deleteItem); } else { userInterface.DisplayItemFoundError(); } break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class WineItemCollection wineItemCollection = new WineItemCollection(); //Display the Welcome Message to the user userInterface.DisplayWelcomeGreeting(); Console.BufferHeight = 5000; Console.BufferWidth = 150; //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 (choice != 7) { switch (choice) { case 1: userInterface.DisplayImportSuccess(); break; case 2: //Print Entire List Of Items string[] allItems = wineItemCollection.GetPrintStringsForAllItems(); if (allItems.Length > 0) { //Display all of the items userInterface.DisplayAllItems(allItems); } else { //Display error message for all items userInterface.DisplayAllItemsError(); } break; case 3: //Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 4: // Add A New Item To The List string[] newItemInformation = userInterface.GetItemInformation(); // Convert the price to a decimal: decimal price = Convert.ToDecimal(newItemInformation[3]); // Set a boolean to hold whether the item is active: bool active = false; // If the input was Y for yes, set active to true: if (newItemInformation[4] == "Y") { active = true; } // Send info to WineItemCollection to add a new item: if (wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2], price, active)) { userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; case 5: // Update an item in the list: string idUpdate = userInterface.GetUpdateId(); if (wineItemCollection.UpdateBeverageItem(idUpdate)) { userInterface.DisplayItemUpdateSuccess(); } else { userInterface.DisplayItemUpdateError(); } break; case 6: // Delete an item from the list: string idDelete = userInterface.GetDeleteId(); if (wineItemCollection.DeleteBeverageItem(idDelete)) { userInterface.DisplayItemDeleteSuccess(); } else { userInterface.DisplayItemDeleteError(); } break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { //Set a constant for the size of the collection const int wineItemCollectionSize = 4000; //Set a constant for the path to the CSV File const string pathToCSVFile = "../../../datafiles/winelist.csv"; //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class IWineCollection wineItemCollection = new WineItemCollection(wineItemCollectionSize); //Create an instance of the CSVProcessor class CSVProcessor csvProcessor = new CSVProcessor(); //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 (choice != 5) { switch (choice) { case 1: //Load the CSV File bool success = csvProcessor.ImportCSV(wineItemCollection, pathToCSVFile); if (success) { //Display Success Message userInterface.DisplayImportSuccess(); } else { //Display Fail Message userInterface.DisplayImportError(); } break; case 2: //Print Entire List Of Items string[] allItems = wineItemCollection.GetPrintStringsForAllItems(); if (allItems.Length > 0) { //Display all of the items userInterface.DisplayAllItems(allItems); } else { //Display error message for all items userInterface.DisplayAllItemsError(); } break; case 3: //Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 4: //Add A New Item To The List string[] newItemInformation = userInterface.GetNewItemInformation(); if (wineItemCollection.FindById(newItemInformation[0]) == null) { wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2]); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { //Creates a new connection to the Database BeverageJKoehlerEntities bevEntities = new BeverageJKoehlerEntities(); //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class IWineCollection wineItemCollection = new WineItemCollection(bevEntities); //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 (choice != 7) { switch (choice) { case 1: //Check the Database Connection. if (bevEntities != null) { //Display Success Message userInterface.DisplayImportSuccess(); } else { //Display Fail Message userInterface.DisplayImportError(); } break; case 2: //Print Entire List Of Items string[] allItems = wineItemCollection.GetPrintStringsForAllItems(); if (allItems.Length > 0) { //Display all of the items userInterface.DisplayAllItems(allItems); } else { //Display error message for all items userInterface.DisplayAllItemsError(); } break; case 3: //Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 4: //Add A New Item To The List string[] newItemInformation = userInterface.GetNewItemInformation(); if (wineItemCollection.FindById(newItemInformation[0]) == null) { wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2], newItemInformation [3], newItemInformation[4]); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; //Update an existing item in the database case 5: string[] updatedItemInformation = userInterface.GetNewItemInformation(); if (wineItemCollection.FindById(updatedItemInformation[0]) == null) { userInterface.DisplayItemFoundError(); } else { wineItemCollection.UpdateItem(updatedItemInformation[0], updatedItemInformation[1], updatedItemInformation[2], updatedItemInformation[3], updatedItemInformation[4]); } break; //Remove an existing item from the database case 6: string itemToRemove = userInterface.DisplayItemRemovalDialogue(); wineItemCollection.RemoveItem(itemToRemove); break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }
static void Main(string[] args) { //Set a constant for the size of the collection const int wineItemCollectionSize = 4000; //Create an instance of the UserInterface class UserInterface userInterface = new UserInterface(); //Create an instance of the WineItemCollection class IWineCollection wineItemCollection = new WineItemCollection(wineItemCollectionSize); //Get access to the collection of tables BeverageBCampbellEntities beverageEntities = new BeverageBCampbellEntities(); //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 (choice != 7) { switch (choice) { case 1: //Load the CSV File //bool success = csvProcessor.ImportCSV(wineItemCollection, pathToCSVFile); bool success; try { foreach (Beverage bev in beverageEntities.Beverages) { wineItemCollection.AddNewItem(bev.id, bev.name, bev.pack); } success = true; } catch { success = false; } if (success) { //Display Success Message userInterface.DisplayImportSuccess(); } else { //Display Fail Message userInterface.DisplayImportError(); } break; case 2: //Print Entire List Of Items string[] allItems = wineItemCollection.GetPrintStringsForAllItems(); if (allItems.Length > 0) { //Display all of the items userInterface.DisplayAllItems(allItems); } else { //Display error message for all items userInterface.DisplayAllItemsError(); } break; case 3: //Search For An Item string searchQuery = userInterface.GetSearchQuery(); string itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); } else { userInterface.DisplayItemFoundError(); } break; case 4: //Add A New Item To The List //ID Description Pack string[] newItemInformation = userInterface.GetNewItemInformation(); if (wineItemCollection.FindById(newItemInformation[0]) == null) { wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2]); userInterface.DisplayAddWineItemSuccess(); } else { userInterface.DisplayItemAlreadyExistsError(); } break; case 5: //Update an existing item searchQuery = userInterface.GetSearchQuery(); itemInformation = wineItemCollection.FindById(searchQuery); if (itemInformation != null) { userInterface.DisplayItemFound(itemInformation); string[] replaceItemInformation = userInterface.GetNewItemInformation(); wineItemCollection.Overwrite(searchQuery, replaceItemInformation[0], replaceItemInformation[1], replaceItemInformation[2]); } else { userInterface.DisplayItemFoundError(); } break; case 6: //Delete an existing item searchQuery = userInterface.GetSearchQuery(); wineItemCollection.Delete(searchQuery); break; } //Get the new choice of what to do from the user choice = userInterface.DisplayMenuAndGetResponse(); } }