public static void RunShoppingMenu(StoreInventory currentInventory, ShoppingCart userCart) { char loopBreaker; do { Console.Clear(); categories.Clear(); foreach (var item in currentInventory) { if (!categories.Contains(item.ItemCategory)) { categories.Add(item.ItemCategory); } } menuOptions(); initialUserInput = Console.ReadLine(); Console.WriteLine(); do { do { if (IntegerValidator.Validate(initialUserInput)) { startMenuChoice = int.Parse(initialUserInput); isValid = true; } else { Console.Clear(); menuOptions(); initialUserInput = Console.ReadLine(); isValid = false; } } while (!isValid); if (startMenuChoice > 0 && startMenuChoice <= categories.Count) { CategorySelectionApp selections = new CategorySelectionApp(startMenuChoice, categories); selections.categorySelector(currentInventory, userCart); isNotMenuChoice = false; } else { Console.Clear(); Console.Write("Not a valid option. "); menuOptions(); initialUserInput = Console.ReadLine(); isNotMenuChoice = true; } } while (isNotMenuChoice); Console.WriteLine("Do you wish to continue adding items to your cart, or checkout? (enter y to keep adding/enter n to checkout): "); //ask user to if they want to continue loopBreaker = IsValidLoopBreaker(Console.ReadLine()); //storing answer and if it's valid input } while (loopBreaker == 'y'); }
static void Main(string[] args) { StoreItem test = new StoreItem(); List <string> tester = test.FileReader(); //foreach (var line in tester) //{ // Console.WriteLine(line); //} //Console.WriteLine(test.ReturnItemName(tester)); StoreItem testItem = new StoreItem(); //testItem = test.ReturnStoreItem(tester); //Console.WriteLine($"{testItem.NameOfItem} {testItem.ItemQuantity} {testItem.ItemPrice} {testItem.ItemCategory}"); StoreInventory testing = new StoreInventory(); List <StoreItem> anotherTest = new List <StoreItem>(); anotherTest = testing.GenerateStoreInventory(); //for (int i = 0; i < anotherTest.Count; i++) //{ // Console.WriteLine(anotherTest[i]); //} foreach (var line in anotherTest) { Console.WriteLine($"{line.NameOfItem} {line.ItemQuantity} {line.ItemPrice}{line.ItemCategory}"); } }
public static void ResetInventoryDatabase(StoreInventory currentInventory) { string newInventoryFileString = ""; foreach (StoreItem item in currentInventory) { newInventoryFileString += item.NameOfItem + ","; newInventoryFileString += "25,"; newInventoryFileString += item.ItemPrice + ","; newInventoryFileString += item.ItemCategory + System.Environment.NewLine; } File.WriteAllText(FileLocation.location, newInventoryFileString); }
public void categorySelector(StoreInventory currentInventory, ShoppingCart userCart) { currentInventory.GenerateStoreInventory(userCart); Console.Clear(); Console.WriteLine("Which item would you like to purchase? (Select from the folowing numbers)"); int i = 1; foreach (var item in currentInventory.TotalStoreInventory) { if (item.ItemCategory == categories[userMenuSelection - 1]) { Console.WriteLine("{0,-20} {1,-10:N1} {2,10}", $"{i} {item.NameOfItem}", $"QTY: {item.ItemQuantity}", $"Price: ${NumberToDollarFormat.Execute(item.ItemPrice)}"); tempList.Add(item); i++; } } DislayListOfItems(userCart); }
public void RunStore() { do { Console.Clear(); Console.WriteLine("\nWelcome to B#, your number one stop for the latest in digital fashion! \nSelect below from the following options:\n"); Console.WriteLine("[1] Shop \n[2] About \n[3] Exit"); initalUserInput = Console.ReadLine(); do { if (IntegerValidator.Validate(initalUserInput)) { startMenuChoice = int.Parse(initalUserInput); isValid = true; } else { Console.Clear(); menuOptions(); initalUserInput = Console.ReadLine(); isValid = false; } } while (!isValid); switch (startMenuChoice) { case 1: do { Console.Clear(); ShoppingMenu.RunShoppingMenu(inventoryPull, usersCart); Console.Clear(); double userSubTotal = usersCart.calculateSubtotal(usersCart.ItemstoPurchase); Payment userPayment = new Payment(userSubTotal, usersCart); userPayment.CalculatedSalesTaxTotal(); double grandTotal = userPayment.CalculatedGrandTotal(); userPayment.MethodOfPayment(); //Receipt userReceipt = new Receipt(grandTotal, userSubTotal, usersCart.ItemstoPurchase); //userReceipt.PrintReceipt(); inventoryPull.GenerateStoreInventory(usersCart); StoreInventory.UpdateInventoryDatabase(inventoryPull); usersCart = new ShoppingCart(); Console.WriteLine("\nWould Like make another transaction or head to the main menu?\n"); Console.WriteLine("[1] New Transaction \n[2] Main Menu\n"); nextChoiceAfterTransaction = Console.ReadLine(); do { if (IntegerValidator.Validate(nextChoiceAfterTransaction)) { shoppingMenuChoice = int.Parse(nextChoiceAfterTransaction); isValid = true; } else { Console.Clear(); menuOptions(); nextChoiceAfterTransaction = Console.ReadLine(); isValid = false; } } while (!isValid); if (shoppingMenuChoice == 1) { isShoppingAgain = true; } else { isShoppingAgain = false; } } while (isShoppingAgain); isNotMenuChoice = true; break; case 2: Console.Clear(); Console.WriteLine("\nB# is a contemporary clothing store serving all of the latest fashion " + "for women, men, and children. We carry a vast selection of clothing, shoes, accessories, and jewelry. " + "Whether you’re shopping for an amazing pair of shoes or the perfect outfit for an event, remember to always BE SHARP!\n"); Console.WriteLine("Acceptable forms of payment include cash, credit card, or check only.\n"); Console.Write("Press 'Enter' to return to main menu..."); Console.ReadLine(); Console.Clear(); isNotMenuChoice = true; break; case 3: Console.Clear(); Console.WriteLine("Thank you and B#!"); isNotMenuChoice = false; break; default: Console.Clear(); Console.Write("Not a valid option. "); isNotMenuChoice = true; break; } } while (isNotMenuChoice); StoreInventory.ResetInventoryDatabase(inventoryPull); // ^^^^^^^^^^^^^^^^^^ //I added this in case we need to reset the inventory when we close the program. //Idk if we want this, but it's here just in case. }