public ActionResult Index(CompanyProduct product, FormCollection form)
        {
            if (Session["ShoppingCart"] == null)
            {
                ShoppingCart            = new List <SalesLineItem>();
                Session["ShoppingCart"] = ShoppingCart;
            }

            // add productversions to product
            ServiceProduct service = new ServiceProduct();

            product = service.GetProductById(product.StyleNumber);

            var selectedColor  = form.Get("colors");
            var selectedSize   = form.Get("sizes");
            int selectedAmount = Int32.Parse(form.Get("amount"));

            CompanyProductVersion prodVer = product.GetProductVersion(selectedSize, selectedColor);

            ConvertDataModel converter = new ConvertDataModel();

            if (prodVer != null)
            {
                SalesLineItem lineitem = new SalesLineItem()
                {
                    amount         = selectedAmount,
                    Product        = converter.ConvertFromCompanyProduct(product),
                    ProductVersion = converter.ConvertFromCompanyProductVersion(prodVer),
                    Price          = (selectedAmount * product.Price)
                };
                ShoppingCart = (List <SalesLineItem>)Session["ShoppingCart"];
                // check if item is already in cart
                if (ItemAlreadyExists(lineitem))
                {
                    foreach (var item in ShoppingCart)
                    {
                        if (item.Product.StyleNumber == lineitem.Product.StyleNumber && item.ProductVersion.SizeCode.Equals(lineitem.ProductVersion.SizeCode) && item.ProductVersion.ColorCode.Equals(lineitem.ProductVersion.ColorCode))
                        {
                            item.amount += lineitem.amount;
                        }
                    }
                }
                else
                {
                    ShoppingCart.Add(lineitem);
                }
            }
            else
            {
                return(RedirectToAction("NotInStock", "Product", new { id = product.StyleNumber }));
            }

            Session["ShoppingCart"] = ShoppingCart;

            return(RedirectToAction("index", "Cart"));
        }
        public void TestGetProductVersion()
        {
            //Arrange
            CompanyProduct product = testservice.GetProductById(3);

            //Act
            CompanyProductVersion prodver = product.GetProductVersion("m", "Blue");

            //Assert
            Assert.IsTrue(prodver != null);
        }