// Shows the inventory of a specific store ****************************** public static void ShowInventory(int input) { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { var data = context.StoreInventory.Where(i => i.StoreId == input).ToList(); foreach (var x in data) { System.Console.WriteLine($"{x.ProductId}: {x.ProductName} : Price: ${x.ProductPrice}"); } } }
// Shows alll products in the products table ****************************** public static void ShowProducts() { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { var data = context.Products.ToList(); int i = 1; foreach (var item in data) { System.Console.WriteLine($"{item.ProductId} : {item.ProductName}"); i++; } } }
// Shows List of store locations ****************************** public static void ShowStores() { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { var data = context.Store.ToList(); int i = 1; foreach (var item in data) { System.Console.WriteLine($"{item.StoreId}. {item.StoreName} : {item.Address} {item.City} {item.State} {item.ZipCode}"); i++; } } System.Console.WriteLine("\n\n"); }
// Place Customer Orders public static void PlaceOrder() { bool status = true; System.Console.WriteLine("Please enter your email address"); string cEmail = Console.ReadLine(); do { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { StoreData.ShowStores(); System.Console.WriteLine("Please select the cooresponding number of the store you would like to visit"); int customerChoice = int.Parse(Console.ReadLine()); System.Console.Clear(); ProductData.ShowInventory(customerChoice); System.Console.WriteLine("Please enter the cooresponding number of the item you would like to purchase"); int input = int.Parse(Console.ReadLine()); System.Console.WriteLine("\nPlease Enter the quantity you would like to purchase"); int purchaseQuantity = int.Parse(Console.ReadLine()); var pPrice = context.StoreInventory.First(pp => pp.ProductId == input).ProductPrice; var pName = context.StoreInventory.First(pn => pn.ProductId == input).ProductName; var totalPrice = pPrice * purchaseQuantity; var newOrder = new BalloonParty.Data.Entities.CustomerOrders { CustomerEmail = cEmail, FullProductCount = purchaseQuantity, TotalPrice = totalPrice, ProductName = pName, OrderDate = DateTime.Now, }; context.CustomerOrders.Add(newOrder); context.SaveChanges(); System.Console.WriteLine($"\n Your order has been submitted: {pName}: Quantity {purchaseQuantity}: Total Price ${totalPrice}"); System.Console.WriteLine("\nWould you like to place another order from the same store, y/n , no will bring you back to the main menu"); string userInput = Console.ReadLine(); if (userInput == "n") { System.Console.Clear(); status = false; userInterface.userMainMenu(); } } }while(status); }
// This allows a store to order products for their store from the warehouse ****************************** public static void OrderProducts() { StoreData.ShowStores(); System.Console.WriteLine("Please enter your Store Number"); int storeID = int.Parse(Console.ReadLine()); System.Console.Clear(); ShowProducts(); bool status = true; do { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { System.Console.WriteLine("\nPlease enter the cooresponding number of the item you would like to order"); int input = int.Parse(Console.ReadLine()); System.Console.WriteLine("\nPlese enter the ammount you would like in your inventory"); int amount = int.Parse(Console.ReadLine()); string pName = context.Products.First(p => p.ProductId == input).ProductName; int pID = context.Products.First(p => p.ProductId == input).ProductId; int sID = context.Store.First(s => s.StoreId == input).StoreId; decimal pPrice = context.Products.First(pr => pr.ProductId == input).ProductPrice; var addProduct = new BalloonParty.Data.Entities.StoreInventory { StoreId = sID, ProductId = pID, ProductName = pName, ProductCount = amount, ProductPrice = pPrice, }; SubtractFromInventory(pID, amount); context.StoreInventory.Add(addProduct); context.SaveChanges(); System.Console.WriteLine("\nWould You Like to Add More Product to Your Store y/n"); string answer = Console.ReadLine(); if (answer == "n") { System.Console.Clear(); status = false; storeInterface.storeMainMenu(); } System.Console.Clear(); } }while(status); }
// Adds Store to Database ****************************** public static void AddStore() { bool status = true; do { System.Console.WriteLine("Please Enter Your Store Name"); string storeName = Console.ReadLine(); System.Console.WriteLine("Please Enter Your Store Street Address"); string storeAddress = Console.ReadLine(); System.Console.WriteLine("Please Enter The City"); string storeCity = Console.ReadLine(); System.Console.WriteLine("Please Enter The State"); string storeState = Console.ReadLine(); System.Console.WriteLine("Please Enter The Zip Code"); int storeZipCode = int.Parse(Console.ReadLine()); using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { var newStore = new BalloonParty.Data.Entities.Store { StoreName = storeName, Address = storeAddress, City = storeCity, State = storeState, ZipCode = storeZipCode, }; context.Store.Add(newStore); context.SaveChanges(); System.Console.WriteLine($"Store : {storeName} has been added"); System.Console.WriteLine("Would you like to add another store y/n"); string x = Console.ReadLine(); if (x == "n") { System.Console.Clear(); status = false; adminInterface.adminMainMenu(); } } } while(status); }
// Shows Customer Orders by Customer Email **************************** public static void ShowCustomersOrders() { bool status = true; System.Console.WriteLine("Please enter your email address"); string cEmail = Console.ReadLine(); try { using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { var data = context.CustomerOrders.Where(e => e.CustomerEmail == cEmail).ToList(); foreach (var x in data) { System.Console.WriteLine($"Order Number {x.CustomerOrderId} : Order Date {x.OrderDate} : Product {x.ProductName} : Amount {x.FullProductCount} : Total Price {x.TotalPrice}"); } } } catch (Exception) { System.Console.WriteLine("You Do Not Have Any Order History"); } do { System.Console.WriteLine("\n\n"); System.Console.WriteLine("Press '1' to return to the main menu or '2' to exit application"); int keyPress = int.Parse(Console.ReadLine()); if (keyPress == 1) { System.Console.Clear(); status = false; userInterface.userMainMenu(); } if (keyPress == 2) { System.Console.Clear(); status = false; Environment.Exit(-1); } }while(status); }
// Main Login Screen ****************************** public static void mainLogin() { bool status = true; int newInput = 0; do { System.Console.WriteLine("Please select if you are a customer, a store, or an admin\n1: Customer\n2: Store\n3: Admin"); string input = Console.ReadLine(); if (input == "1" || input == "2" || input == "3") { try { newInput = int.Parse(input); status = false; } catch (System.Exception) { System.Console.WriteLine("Invalid input, please try again"); } } }while(status); System.Console.WriteLine("Please select if you are a customer, a store, or an admin or press zero to exit.\n1: Customer\n2: Store\n3: Admin\n\n0: Exit"); // int input; // while (!int.TryParse(Console.ReadLine(), out input)) // { // Console.WriteLine("Invalid input. Try again"); // } if (newInput == 0) { Environment.Exit(-1); } System.Console.WriteLine("\nPLEASE LOGIN"); System.Console.WriteLine("Please Enter Your Login ID"); string email = Console.ReadLine(); System.Console.WriteLine("\nPlease Enter Your Password"); string pw = Console.ReadLine(); using (var context = new BalloonParty.Data.Entities.BalloonPartyContext()) { try { if (newInput == 1) { var users = context.Customer.First(c => c.EmailAddress == email && c.CustomerPw == pw); System.Console.Clear(); userInterface.userMainMenu(); } if (newInput == 2) { var storeUser = context.Store.First(s => s.StoreUsername == email && s.StorePw == pw); System.Console.Clear(); storeInterface.storeMainMenu(); } if (newInput == 3) { var rootuser = context.RootUser.First(r => r.RootName == email && r.RootPw == pw); System.Console.Clear(); adminInterface.adminMainMenu(); } } catch (Exception) { System.Console.WriteLine("Invalid Login\n\n"); System.Console.Clear(); mainLogin(); } } }