// Function that // [1] displays inventory // [2] displays inventory with True/False option public void DisplayAllInventory(int threshold, int boolOption) { // get store products, filter them Inventory inv = new Inventory(CurrentLocation); List <Product> inventory = inv.Products; switch (boolOption) { // false is selected, select those w/ stock lvl same or above threshold case 0: inventory = (from i in inventory where i.StockLevel >= threshold select i).ToList <Product>(); break; // true is selected, select items that requires re-stocking case 1: inventory = (from i in inventory where i.StockLevel < threshold select i).ToList <Product>(); break; // other values, don't filter } // if nothing to process, just exit if (inventory.Count() == 0) { Console.WriteLine("=============================================="); Console.WriteLine(" There are no products to process "); Console.WriteLine("=============================================="); Console.WriteLine(); return; } // View Component new InventoryTable(inventory, threshold); // select choice, if q is selected (which is 0), just exit int choice = SelectItem(inventory, "Enter request to process (press q to quit): "); if (choice == 0) { return; } Product product = (from i in inventory where i.Id == choice select i).First(); // create a stock request StockRequest request = new StockRequest(); request.ProductName = product.Name; request.Quantity = threshold - product.StockLevel; request.StoreName = CurrentLocation; // When user selects an item that doesn't have to be re-stocked // if user insist, request for 0 more stock, otherwise just exit if (product.StockLevel >= threshold) { Console.WriteLine("The product with ID of {0} does not have to be re-stocked", product.Id); Console.Write("Do you wish to continue anyway? "); if (SelectBoolean() == false) { return; // exit immediately } // amount needed for restock is 0 request.Quantity = 0; } // save if (request.Save()) { Console.WriteLine("Request has been dispatched"); } else { Console.WriteLine("Request failed. Something has gone wrong"); } }