public void GetSearchedInventories(string searchTerm) { int tracker = 0; LineSeparator line = new LineSeparator(); List <Inventory> customerList = _inventoryBL.GetInventory(); foreach (Inventory x in customerList) { if (x.InventoryName.Contains(searchTerm) || x.Location.LocationName.Contains(searchTerm) || x.Product.ProductName.Contains(searchTerm) || x.InventoryID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(x); tracker++; } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check spelling. \nReminder: This search system is Case Sensitive :)"); } line.LineSeparate(); Console.WriteLine("Here are your results! Press enter to search again."); Console.ReadLine(); }
public void GetSearchedProducts(string searchTerm) { int tracker = 0; LineSeparator line = new LineSeparator(); List <Product> productList = _productBL.GetProduct(); foreach (Product product in productList) { if (product.ProductName.Contains(searchTerm) || product.Manufacturer.Contains(searchTerm) || product.ProductID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(product); tracker++; } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check product spelling. \nThis system is Case Sensitive :)"); } line.LineSeparate(); }
public void GetFilteredCustomersForProcessing(string searchTerm, ref Customer resultingCustomer, ref bool stay) { int tracker = 0; LineSeparator line = new LineSeparator(); List <Customer> customerList = _customerBL.GetCustomers(); foreach (Customer customer in customerList) { if (customer.FName.Contains(searchTerm) || customer.LName.Contains(searchTerm) || customer.CustomerID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(customer); tracker++; //for the first found customer, store in our foundcustomer object, but don't do it again if (tracker == 1) { resultingCustomer.FName = customer.FName; resultingCustomer.LName = customer.LName; resultingCustomer.CustomerID = customer.CustomerID; resultingCustomer.Username = customer.Username; resultingCustomer.PasswordHash = customer.PasswordHash; } } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)"); } //if the tracker only happened once, that means one customer with the matching value was found, so we pass that customer reference //back out to our manager system :) if (tracker == 1) { line.LineSeparate(); Console.WriteLine("We have found one customer with the details displayed above."); Console.WriteLine("Is this the correct customer?"); Console.WriteLine("[0] Yes"); Console.WriteLine("[1] No"); switch (Console.ReadLine()) { case "0": stay = false; break; case "1": Console.WriteLine("Okay, please search again to find the correct customer. \nPress enter to continue."); Console.ReadLine(); break; default: Console.WriteLine("This is not a valid menu option!"); break; } } line.LineSeparate(); }
public void GetAllCustomers() { LineSeparator line = new LineSeparator(); List <Customer> customerList = _customerBL.GetCustomers(); foreach (Customer customer in customerList) { line.LineSeparate(); Console.WriteLine(customer); } line.LineSeparate(); }
public void GetSearchedCustomers(string searchTerm) { int tracker = 0; LineSeparator line = new LineSeparator(); List <Customer> customerList = _customerBL.GetCustomers(); List <Order> orderList = _orderBL.GetOrders(); List <Order> filteredOrderList = new List <Order>(); Customer firstCustomer = new Customer(); foreach (Customer customer in customerList) { if (customer.FName.Contains(searchTerm) || customer.LName.Contains(searchTerm) || customer.CustomerID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(customer); tracker++; if (tracker == 1) { firstCustomer = customer; foreach (Order o in orderList) { if (o.CustomerID == firstCustomer.CustomerID) { filteredOrderList.Add(o); } } } } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)"); } if (tracker == 1) { line.LineSeparate(); Console.WriteLine("Single customer found! Here is a detailed view of customer information: "); line.LineSeparate(); Console.WriteLine(firstCustomer.ToString()); line.LineSeparate(); Console.WriteLine("Customer order history: "); foreach (Order o in filteredOrderList) { line.LineSeparate(); Console.WriteLine(o.ToString()); } } line.LineSeparate(); }
/* * public void InventorySearchForOrdering(Location location) * { * bool stay = true; * do * { * Console.WriteLine($"Welcome to the product search area for our {location.LocationName} location!"); * Console.WriteLine($"Type in \"all\" to view a list of all products at the {location.LocationName} location."); * Console.WriteLine("Type in \"exit\" to return to the previous menu."); * * * * String userInput = Console.ReadLine(); * * switch (userInput) * { * case "exit": * //return to manager menu - value "true" should still be assigned to manager menu loop. * stay = false; * break; * case "all": * //return a list of all customers - BUILD IN METHOD TO INTERACT WITH BL * GetAllInventories(); * break; * default: * GetSearchedInventories(userInput); * //return specified string values of store inventories * //GetSearchedStoreInventories(userInput); * break; * } * * } while (stay); * * } */ public void GetAllInventories() { LineSeparator line = new LineSeparator(); List <Inventory> inventoryList = _inventoryBL.GetInventory(); foreach (Inventory x in inventoryList) { line.LineSeparate(); Console.WriteLine(x); } line.LineSeparate(); }
public void GetAllProducts() { LineSeparator line = new LineSeparator(); List <Product> productList = _productBL.GetProduct(); foreach (Product product in productList) { line.LineSeparate(); Console.WriteLine(product); } line.LineSeparate(); }
public void SortOrdersByHighPrice() { LineSeparator line = new LineSeparator(); List <Order> orderList = _orderBL.GetOrders(); List <List <OrderItem> > listOfOrderItemsPerOrder = new List <List <OrderItem> >(); foreach (Order o in orderList) { List <OrderItem> orderItems = _orderItemsBL.GetOrderItems(o.OrderID); listOfOrderItemsPerOrder.Add(orderItems); } List <decimal> orderValues = new List <decimal>(); List <decimal> orderSums = new List <decimal>(); //parse order values to foreach (List <OrderItem> oL in listOfOrderItemsPerOrder) { foreach (OrderItem o in oL) { Product productTracker = _productBL.GetProductByID(o.productID); orderValues.Add(o.OrderItemsQuantity.Value * productTracker.ProductPrice.Value); } orderSums.Add(orderValues.Sum()); } int i = 0; foreach (Order o in orderList) { o.TotalCost = orderSums[i]; i++; } //we FINALLY have a list of orders with sums lol. //CHANGE THIS PART FOR SORTING FROM LOWEST TO HIGHEST/ HIGHEST TO LOWEST List <Order> sortedList = orderList.OrderBy(o => o.TotalCost).ToList(); foreach (Order o in sortedList) { line.LineSeparate(); Console.WriteLine($"| Order Price: {o.TotalCost} | Order Date: {o.OrderDate} | Order ID: {o.OrderID} | Customer ID: {o.CustomerID} | Location ID: {o.LocationID} |"); line.LineSeparate(); } }
public void GetAllOrders() { LineSeparator line = new LineSeparator(); List <Order> orderList = _orderBL.GetOrders(); foreach (Order order in orderList) { line.LineSeparate(); Console.WriteLine($"| Order ID: {order.OrderID} | Order Date: {order.OrderDate} | Customer ID: {order.CustomerID} | Location ID: {order.LocationID}"); //Console.WriteLine(order.OrdersWithCustomers()); line.LineSeparate(); } line.LineSeparate(); }
public void GetSearchedOrders(string searchTerm) { int tracker = 0; LineSeparator line = new LineSeparator(); List <Order> orderList = _orderBL.GetOrders(); Order singleOrderFound = new Order(); List <OrderItem> itemsInOrder = new List <OrderItem>(); foreach (Order order in orderList) { string fullname = order.Customer.FName + " " + order.Customer.LName; if (order.Customer.FName.Contains(searchTerm) || order.Customer.LName.Contains(searchTerm) || order.OrderID.ToString().Contains(searchTerm) || order.LocationID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(order.OrdersWithCustomers()); tracker++; if (tracker == 1) { itemsInOrder = _orderItemsBL.GetOrderItems(order.OrderID); singleOrderFound = order; } } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check customer name spelling"); } else if (tracker == 1) { line.LineSeparate(); Console.WriteLine($"Single order found! Here are the specific details regarding order {singleOrderFound.OrderID}:"); Console.WriteLine("Customer Info:"); Console.WriteLine($"Customer Name: {singleOrderFound.Customer.FName} {singleOrderFound.Customer.LName}"); foreach (OrderItem o in itemsInOrder) { line.LineSeparate(); Console.WriteLine($"| Product ID: {o.productID} | Product Quantity: {o.OrderItemsQuantity} |"); } } line.LineSeparate(); }
public void SortOrdersByOldest() { LineSeparator line = new LineSeparator(); List <Order> orderList = _orderBL.GetOrders(); orderList.Sort((x, y) => DateTime.Compare(x.OrderDate, y.OrderDate)); int tracker = 0; foreach (Order o in orderList) { line.LineSeparate(); Console.WriteLine($"| Order Date: {o.OrderDate} | Order ID: {o.OrderID} | Customer ID: {o.CustomerID} | Location ID: {o.LocationID} |"); if (tracker == 10) { break; } } line.LineSeparate(); Console.WriteLine("Press enter to continue searching!"); Console.ReadLine(); }
public void PlaceOrder() { Console.Clear(); AsciiHeader.AsciiHead(); Customer customer = new Customer(); customerSearch.Start(customer); //we have the customer //we need the location next Boolean stay = true; Location location = new Location(); while (stay) { Console.Clear(); AsciiHeader.AsciiHead(); Console.WriteLine("Please select customer store location"); Console.WriteLine("[0] Tampa"); Console.WriteLine("[1] Orlando"); string userInput = Console.ReadLine(); switch (userInput) { case "0": location = _locationBL.GetSpecifiedLocation(20000); stay = false; break; case "1": location = _locationBL.GetSpecifiedLocation(20001); stay = false; break; default: Console.WriteLine("Not a valid menu option!"); break; } //Console.WriteLine(location); } Cart cart = new Cart(); //Console.WriteLine(customer); //now, with both a customer and location, we can create a cart OR call a cart //if the customer's cart already exists, it will use that cart try { cart = _cartBL.FindCart(customer.CustomerID); } catch (Exception ex) { Log.Error(ex, "Something went wrong"); } //before we start assigning products to carts, we need to know our inventory ID list to pass into the product search List <Inventory> inventories = _inventoryBL.GetInventory(); List <Inventory> specificInventories = new List <Inventory>(); foreach (Inventory i in inventories) { if (i.InventoryLocation == location.LocationID) { specificInventories.Add(i); } } //THIS is where we would want to call our product search menu // we want to basically run this, then on complete, create a new cartproduct object // we can check against inventory amount here!!! try { productSearch.Start(location, cart.CartID, inventories); } catch (System.ArgumentOutOfRangeException ex) { Log.Error(ex, "Someone tried to order a product that didn't exist"); Console.WriteLine("Sorry, the requested product does not exist at your location.\nPlease try again."); Console.WriteLine("Press enter to continue"); Console.ReadLine(); productSearch.Start(location, cart.CartID, inventories); } List <CartProducts> cartProducts = _cartProductsBL.FindCartProducts(cart.CartID); decimal costTotal = 0; LineSeparator line = new LineSeparator(); Console.WriteLine("Please confirm your order for processing:"); Console.WriteLine("Products Ordered:"); foreach (CartProducts x in cartProducts) { Product currentProduct = _productBL.GetProductByID(x.ProductID); decimal currentProductCost = currentProduct.ProductPrice.Value * x.ProductCount.Value; costTotal = costTotal + currentProductCost; line.LineSeparate(); Console.WriteLine($"| Product Name: {currentProduct.ProductName} | Product Quantity: {x.ProductCount} | Individual Product Cost: {currentProductCost}"); line.LineSeparate(); } line.LineSeparate(); Console.WriteLine($"| Total Cost: {costTotal}"); Console.WriteLine("Is this order accurate?"); Console.WriteLine("[0] Yes"); Console.WriteLine("[1] No"); string confirmationInput; confirmationInput = Console.ReadLine(); bool stayConfirm = true; bool processOrder = true; while (stayConfirm) { switch (confirmationInput) { case "0": Console.WriteLine("Fantastic! Please press enter to begin order processing."); Console.ReadLine(); processOrder = true; stayConfirm = false; break; case "1": Console.WriteLine("Okay, please update your order as necessary and return to this confirmation page."); Console.WriteLine("Please press enter."); Console.ReadLine(); processOrder = false; stayConfirm = false; break; default: Console.WriteLine("Not a valid menu option!"); break; } } if (processOrder == true) { //time to process the order Order finalizedOrder = new Order(); finalizedOrder.CartID = cart.CartID; finalizedOrder.Customer = customer; finalizedOrder.CustomerID = customer.CustomerID; finalizedOrder.LocationID = location.LocationID; finalizedOrder.OrderDate = DateTime.Now; _orderBL.AddOrder(finalizedOrder); //we will need to retrieve the order that was just added for it's ID! //this will let us process what items were included in the order Order orderForItemsProcessing = _orderBL.GetSpecifiedOrder(finalizedOrder.OrderDate); //create a new order item list List <OrderItem> orderItems = new List <OrderItem>(); //add each new orderItem to our database foreach (CartProducts p in cartProducts) { OrderItem orderProcessing = new OrderItem { OrderItemsQuantity = p.ProductCount, OrderID = orderForItemsProcessing.OrderID, productID = p.ProductID, }; _orderItemsBL.AddOrderItem(orderProcessing); } //flush the cart once the order is complete. foreach (CartProducts cartprod in cartProducts) { _cartProductsBL.RemoveCartProducts(cartprod); } Log.Information("Order placed successfully"); Console.WriteLine("Order placed successfully!"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); Console.Clear(); } //we now have EVERYTHING ready (I think) //List<OrderItem> orderItemsToConfirm = _orderItemsBL.GetOrderItems(orderForItemsProcessing.OrderID); //now that we have a cart, we need to find products //then add them to a new cartproducts table so the cart //can reference them //we will call cartproduct BL to create a new cartproduct //every time something is added to the inventory. //then, we can return a list of cartproducts after? //then create an order when products/total are ready! }
public void GetSearchedInventoriesForUpdate(string searchTerm) { Inventory foundInventory = new Inventory(); int tracker = 0; LineSeparator line = new LineSeparator(); List <Inventory> inventoryList = _inventoryBL.GetInventory(); foreach (Inventory inventory in inventoryList) { if (inventory.Product.ProductName.Contains(searchTerm) || inventory.InventoryName.Contains(searchTerm) || inventory.Location.LocationName.Contains(searchTerm) || searchTerm == inventory.InventoryID.ToString()) { line.LineSeparate(); Console.WriteLine(inventory); tracker++; //for the first found inventory, store in our foundinventory object, but don't do it again if (tracker == 1) { foundInventory = inventory; } } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)"); } //if the tracker only happened once, that means one customer with the matching value was found, so we pass that customer reference //back out to our manager system :) if (tracker == 1) { line.LineSeparate(); Console.WriteLine("We have found one inventory from your search. Please see the details displayed above."); Console.WriteLine("Would you like to edit this inventory?"); Console.WriteLine("[0] Yes"); Console.WriteLine("[1] No"); switch (Console.ReadLine()) { case "0": Console.WriteLine($"Please enter the updated product quantity for the {foundInventory.InventoryName} inventory: "); foundInventory.ProductQuantity = Int32.Parse(Console.ReadLine()); //we need to check if the specified inventory has said product in stock for the amount desired Console.WriteLine($"updated inventory quantity: {foundInventory.ProductQuantity}"); _inventoryBL.UpdateInventory(foundInventory); Console.WriteLine("Inventory updated successfully!"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); Console.Clear(); break; case "1": Console.WriteLine("Okay, please search again to find a different inventory. \nPress enter to continue."); Console.ReadLine(); Console.Clear(); break; default: Console.WriteLine("This is not a valid menu option!"); break; } } line.LineSeparate(); }
public void GetFilteredProductsForProcessing(string searchTerm, int cartID, List <Inventory> inventories, Location location) { //keeps track of the product if only 1 product is found Product foundProduct = new Product(); //tracks how many products have been found given the search int tracker = 0; LineSeparator line = new LineSeparator(); //retrieves a list of all products List <Product> productList = _productBL.GetProduct(); //new list intended to filter products down to only those that exist in inventories for our location List <Product> filteredByInventoryProducts = new List <Product>(); //our list of filtered inventories List <Inventory> filteredByLocationInventories = new List <Inventory>(); //filter inventories to only those at our location //if the location ID of this inventory matches our stored location ID, then add it to the list of filtered locations foreach (Inventory i in inventories) { if (i.Location.LocationID == location.LocationID) { filteredByLocationInventories.Add(i); } } //filter products to display only those that exist in one of the found inventories //for each product that we've retrieved, make sure that the product ID matches a product ID stored in an inventory foreach (Product p in productList) { foreach (Inventory i in filteredByLocationInventories) { if (i.ProductID == p.ProductID) { filteredByInventoryProducts.Add(p); } } } foreach (Product product in filteredByInventoryProducts) { if (product.ProductName.Contains(searchTerm) || product.Manufacturer.Contains(searchTerm) || product.ProductID.ToString().Contains(searchTerm)) { line.LineSeparate(); Console.WriteLine(product); tracker++; //for the first found customer, store in our foundcustomer object, but don't do it again if (tracker == 1) { foundProduct.ProductID = product.ProductID; foundProduct.ProductName = product.ProductName; foundProduct.ProductDescription = product.ProductDescription; foundProduct.Manufacturer = product.Manufacturer; foundProduct.ProductPrice = product.ProductPrice; } } } if (tracker == 0) { line.LineSeparate(); Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)"); } //if the tracker only happened once, that means one customer with the matching value was found, so we pass that customer reference //back out to our manager system :) if (tracker == 1) { line.LineSeparate(); Console.WriteLine("We have found one product from your search. Please see the details displayed above."); Console.WriteLine("Would you like to add this product to your cart?"); Console.WriteLine("[0] Yes"); Console.WriteLine("[1] No"); switch (Console.ReadLine()) { case "0": CartProducts cartProduct = new CartProducts(); List <Inventory> inventoriesFiltered = new List <Inventory>(); //we need to check if the specified inventory has said product in stock for the amount desired foreach (Inventory i in inventories) { if (i.ProductID == foundProduct.ProductID && i.InventoryLocation == location.LocationID) { inventoriesFiltered.Add(i); } } Inventory realInventory = inventoriesFiltered[0]; Console.WriteLine($"We currently have {realInventory.ProductQuantity} of these in stock at the {location.LocationName} location!"); Console.WriteLine("Please enter how many you would like to order: "); cartProduct.ProductCount = Int32.Parse(Console.ReadLine()); if (realInventory.ProductQuantity < cartProduct.ProductCount) { Console.WriteLine($"Sorry, we only have {realInventory.ProductQuantity} left in stock at {location.LocationName}.\nPlease enter a lower quantity"); Console.WriteLine("Press enter to continue."); break; } if (cartProduct.ProductCount <= 0) { Console.WriteLine("Sorry, you've entered an invalid value. Please try again"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; } cartProduct.CartID = cartID; cartProduct.ProductID = foundProduct.ProductID; realInventory.ProductQuantity = realInventory.ProductQuantity - cartProduct.ProductCount.Value; Console.WriteLine($"current inventory value: {realInventory.ProductQuantity}"); _cartProductsBL.AddCartProduct(cartProduct); _inventoryBL.UpdateInventory(realInventory); Log.Information($"product added to cart {cartProduct.ProductID}"); Console.WriteLine("Product added to cart successfully!"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case "1": Console.WriteLine("Okay, please search again to find a different product. \nPress enter to continue."); Console.ReadLine(); break; default: Console.WriteLine("This is not a valid menu option!"); break; } } line.LineSeparate(); }