/// <summary>
        /// Where the user selects which store's inventory they want to see
        /// </summary>
        /// <param name="store"></param>
        public IActionResult GetStoreInventory(Stores store)
        {
            //Get inventory of selected store
            var storeInventory = (from Inventory in _db.Inventory
                                  where Inventory.StoreInventory == store.StoreId
                                  select new { Inventory.ItemInInventory, Inventory.ProductCurrentQuantity }).ToList();
            //Get all the product information
            var productInfo = (from Products in _db.Products
                               where  Products.IsInBundle == false
                               select new { Products.ProductName,
                                            Products.ProductDescrip,
                                            Products.Skunum,
                                            Products.UnitPrice }).ToList();
            //Get info on all the products in the inventory
            var inventoryProducts = (from Inventory in storeInventory
                                     from Products in productInfo
                                     where Inventory.ItemInInventory == Products.Skunum && Inventory.ProductCurrentQuantity > 0
                                     select new
            {
                Inventory.ProductCurrentQuantity,
                Products.ProductName,
                Products.ProductDescrip,
                Products.Skunum,
                Products.UnitPrice
            }).ToList();

            //Instantiate list here so it resets with every iteration of this method
            inventoryInfo = new List <InventoryProductInfo>();

            //Store all the inventory's products into a list of our view model data type
            foreach (var product in inventoryProducts)
            {
                InventoryProductInfo item = new InventoryProductInfo();
                item.Skunum                 = product.Skunum;
                item.ProductName            = product.ProductName;
                item.ProductDescrip         = product.ProductDescrip;
                item.UnitPrice              = product.UnitPrice;
                item.ProductCurrentQuantity = product.ProductCurrentQuantity;
                inventoryInfo.Add(item);
            }
            //TODO Add alert for if store inventory is empty (everything out of stock)
            //TODO (maybe) create a new table that gives each product the appropriate logo for their system
            return(View("_ListStoreInventory", inventoryInfo));
        }
        /// <summary>
        /// Adds item to cart when user clicks button
        /// </summary>
        /// <returns></returns>
        public IActionResult AddItemToCart(InventoryProductInfo selectedItem, int?numOrdered)
        {
            if (numOrdered == null)
            {
                numOrdered = (int)1;
            }
            else
            {
                numOrdered = (int)numOrdered;
            }
            //TODO Add a check to make sure quantity isnt more than whats available

            //Not returning anything, just altering the cart list

            //Cart is a list of OrderInformation because that model contains all the relevant info on the ordered Product
            var loggedIn = _cache.Get("loggedInCustomer");

            loggedInCustomer = (Customers)loggedIn;

            var itemCart = _cache.Get("Cart");
            List <OrderInformation> cart = new List <OrderInformation>();

            cart = (List <OrderInformation>)itemCart;

            //Check to see if the product is already in the cart or a new cart item
            OrderInformation newSKU = new OrderInformation();

            newSKU.OrderedProduct       = selectedItem.Skunum;
            newSKU.OrderedProductAmount = selectedItem.OrderedAmt;
            int matchWasFound = 0;

            foreach (var item in cart)
            {
                if (newSKU.OrderedProduct == item.OrderedProduct)
                {
                    matchWasFound++;
                }
            }
            if (matchWasFound != 0)
            {
                //Grab the item from the cart
                var existingItem = StoreMethods.SelectCartItem(newSKU, cart);

                //Update the existing item's ordered amount and the total price for the item
                existingItem.OrderedProductAmount += newSKU.OrderedProductAmount;
                existingItem.UnitPrice             = existingItem.OrderedProductAmount * (existingItem.UnitPrice * (1 - existingItem.ProductDiscount));
                _cache.Set("Cart", cart);
                return(RedirectToAction("GetCustomerStoreInventory"));
            }
            else //If this is the first time this item has been added, create a new cart object
            {
                OrderInformation newCartItem = new OrderInformation();
                newCartItem.OrderedProduct       = selectedItem.Skunum;
                newCartItem.OrderedProductAmount = (int)numOrdered;
                newCartItem.ProductName          = selectedItem.ProductName;
                newCartItem.UnitPrice            = (int)numOrdered * (selectedItem.UnitPrice * (1 - selectedItem.ProductDiscount)); //Total price of that item given the discount and num ordered
                newCartItem.WhoOrdered           = loggedInCustomer.CustomerId;
                newCartItem.StoreOrderedFrom     = loggedInCustomer.DefaultStore;
                newCartItem.IsBundle             = selectedItem.IsBundle;
                newCartItem.IsInBundle           = selectedItem.IsInBundle;
                newCartItem.BundleId             = selectedItem.BundleId;
                cart.Add(newCartItem);    //Add new cart item to our cart
                _cache.Set("Cart", cart); //Set our cart to be the new cart
                return(RedirectToAction("GetCustomerStoreInventory"));
            }
        }
        /// <summary>
        /// Runs the GetInventory action and prints out the inventory of the customer's default store
        /// </summary>
        /// <returns></returns>
        public IActionResult GetCustomerStoreInventory()
        {
            if (!_cache.TryGetValue("loggedInCustomer", out loggedInCustomer))
            {
                //If the user isn't logged in, return to login screen
                return(View("_Login"));
            }
            //Get the logged in customer
            var loggedIn = _cache.Get("loggedInCustomer");

            loggedInCustomer = (Customers)loggedIn;

            //Get inventory of the customer's default store
            var storeInventory = (from Inventory in _db.Inventory
                                  where Inventory.StoreInventory == loggedInCustomer.DefaultStore
                                  select new { Inventory.ItemInInventory, Inventory.ProductCurrentQuantity }).ToList();
            //Get all the product information
            var productInfo = (from Products in _db.Products
                               where Products.IsInBundle == false
                               select new
            {
                Products.ProductName,
                Products.ProductDescrip,
                Products.Skunum,
                Products.UnitPrice,
                Products.ProductDiscount,
                Products.BundleId,
                Products.IsBundle,
                Products.IsInBundle
            }).ToList();
            //Get info on all the products in the inventory
            var inventoryProducts = (from Inventory in storeInventory
                                     from Products in productInfo
                                     where Inventory.ItemInInventory == Products.Skunum && Inventory.ProductCurrentQuantity > 0
                                     select new
            {
                Inventory.ProductCurrentQuantity,
                Products.ProductName,
                Products.ProductDescrip,
                Products.Skunum,
                Products.ProductDiscount,
                Products.UnitPrice,
                Products.BundleId,
                Products.IsBundle,
                Products.IsInBundle
            }).ToList();

            //Instantiate list here so it resets with every iteration of this method
            inventoryInfo = new List <InventoryProductInfo>();

            //Store all the inventory's products into a list of our view model data type
            foreach (var product in inventoryProducts)
            {
                InventoryProductInfo item = new InventoryProductInfo();
                item.Skunum                 = product.Skunum;
                item.ProductName            = product.ProductName;
                item.ProductDescrip         = product.ProductDescrip;
                item.UnitPrice              = product.UnitPrice;
                item.ProductDiscount        = product.ProductDiscount;
                item.ProductCurrentQuantity = product.ProductCurrentQuantity;
                item.IsBundle               = product.IsBundle;
                item.IsInBundle             = product.IsInBundle;
                item.BundleId               = product.BundleId;
                inventoryInfo.Add(item);
            }
            //TODO Add alert for if store inventory is empty (everything out of stock)
            //TODO (maybe) create a new table that gives each product the appropriate logo for their system
            InventoryProductSelect select = new InventoryProductSelect();

            select.inventoryitem = inventoryInfo;
            return(View("_SelectItem", inventoryInfo));
        }