// Method for getting the converted price and sending it to the product page (viewmodel)
        public ActionResult Index(ProductPage currentPage)
        {
            var currencyClient = new CurrencyClient();
            var convertedPrice = currencyClient.GetConvertedFromUsd(currentPage.ProductPrice);

            var viewModel = new ProductPageViewModel();

            viewModel.CurrentPage    = currentPage;
            viewModel.ConvertedPrice = convertedPrice.ToString("C3");

            return(View("~/Views/ProductPage/Index.cshtml", viewModel));
        }
        public ActionResult Index(string productId)
        {
            var cartCookie = this.Request.Cookies.Get("cart");

            if (cartCookie == null || string.IsNullOrWhiteSpace(cartCookie.Value))
            {
                var guid = Guid.NewGuid();
                cartCookie = new HttpCookie("cart", guid.ToString());
                Response.Cookies.Add(cartCookie);
            }

            var contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();
            var productPage       = contentRepository.Get <ProductPage>(new ContentReference(int.Parse(productId)));

            // Creates a new Entity for the cart
            var cartItem = new CartItemEntity();

            cartItem.ProductId    = int.Parse(productId);
            cartItem.ProductName  = productPage.Name;
            cartItem.ProductPrice = int.Parse(productPage.ProductPrice);
            cartItem.UserId       = cartCookie.Value;
            cartItem.Quantity     = 1;

            // Gets the converted price and adds it to the cart Entity
            var currencyClient = new CurrencyClient();
            var convertedPrice = currencyClient.GetConvertedFromUsd(productPage.ProductPrice);

            cartItem.ConvertedPrice = convertedPrice;

            var cartRepository = new CartRepository();

            cartRepository.Save(cartItem, true);

            // Adds the converted price to the viewmodel
            var viewModel = new ProductPageViewModel();

            viewModel.CurrentPage    = productPage;
            viewModel.ConvertedPrice = convertedPrice.ToString("C3");

            return(View("~/Views/ProductPage/Index.cshtml", viewModel));
        }