public void start() { Console.WriteLine("Select a location!"); LocationTask locationtask = new LocationTask(repo); List <Location> Location = locationtask.GetAllLocations(); CartTask cartTask = new CartTask(repo); CartItemTask cartitemtask = new CartItemTask(repo); ProductTask producttask = new ProductTask(repo); Cart cart = cartTask.GetCartByCustomer(1); count = 1; foreach (Location singleLocation in Location) { Console.WriteLine("[" + count + "]"); Console.WriteLine(singleLocation.Name); count++; } userInput = Console.ReadLine(); int Locationid = Int32.Parse(userInput); InventoryTask inventorytask = new InventoryTask(repo); Console.WriteLine("Getting items..."); List <Inventory> Items = inventorytask.GetInventoryByLocation(Locationid); string continueloop = "y"; while (continueloop == "y") { foreach (Inventory Item in Items) { int id = Item.ProductId; Product prod = producttask.GetProduct(id); Console.WriteLine("Product ID: " + id); Console.WriteLine("Item Name: " + prod.Name); Console.WriteLine("Cost: " + prod.Cost); Console.WriteLine("Quantity: " + Item.Quantity); Console.WriteLine(" "); } Console.WriteLine("Select a product (By ID!)"); userInput = Console.ReadLine(); Product chosenproduct = producttask.GetProduct(Int32.Parse(userInput)); CartItem cartitem = new CartItem(); cartitem.ProductId = Int32.Parse(userInput); Console.WriteLine("How many do you want to buy?"); string input = Console.ReadLine(); cartitem.CartId = 1; cartitem.Quantity = Int32.Parse(input); cartitemtask.UpdateCartItem(cartitem); Console.WriteLine("Item has been added!"); Console.WriteLine("Keep adding to cart? (y/n)"); continueloop = Console.ReadLine(); } }
public void start() { do { Console.WriteLine("Select a location!"); List <Location> Location = locationtask.GetAllLocations(); count = 1; foreach (Location singlelocation in Location) { Console.WriteLine("[" + count + "]"); Console.WriteLine(singlelocation.Name); count++; } locationstring = Console.ReadLine(); Console.WriteLine("What would you like to do?"); Console.WriteLine("[1] Check Inventory"); Console.WriteLine("[2] Replenish Inventory"); Console.WriteLine("[3] Go Back"); userInput = Console.ReadLine(); int Locationid = Int32.Parse(locationstring); List <Inventory> Items = inventorytask.GetInventoryByLocation(Locationid); switch (userInput) { case "1": //Pulls up inventory for selected location Console.WriteLine("Getting items..."); foreach (Inventory Item in Items) { int id = Item.ProductId; Product prod = producttask.GetProduct(id); Console.WriteLine("Product ID: " + id); Console.WriteLine("Item Name: " + prod.Name); Console.WriteLine("Quantity: " + Item.Quantity); Console.WriteLine(" "); } break; case "2": //Replenishes inventory Console.WriteLine("Getting items..."); foreach (Inventory Item in Items) { int id = Item.ProductId; Product prod = producttask.GetProduct(id); Console.WriteLine("Product ID: " + id); Console.WriteLine("Item Name: " + prod.Name); Console.WriteLine("Quantity: " + Item.Quantity); Console.WriteLine(" "); } Console.WriteLine("Select an item (by ID)"); userInput = Console.ReadLine(); List <Inventory> inv = inventorytask.GetInventoryByLocation(Locationid); Console.WriteLine("How much of this item is now in stock?"); string newquantity = Console.ReadLine(); foreach (Inventory item in inv) { if (item.ProductId == Int32.Parse(userInput)) { Inventory updatedinv = inventorytask.GetInventory(item.InventoryId); updatedinv.Quantity = Int32.Parse(newquantity); inventorytask.UpdateInventory(updatedinv); Console.WriteLine("Item has been restocked!"); } } break; default: //invalid input message; Console.WriteLine("Make a valid selection!"); break; } }while (!userInput.Equals("3")); }