Exemplo n.º 1
0
        public ActionResult Index()
        {
            var productWrapper = new ProductWrapper();
            var getAllProducts = productWrapper.GetAllProducts();

            return(View(getAllProducts));
        }
Exemplo n.º 2
0
        public void AddToCard(int productid)
        {
            var allProducts = _productWrapper.GetAllProducts();

            var cart     = this.GetCart();
            var cartItem = cart.Find(c => c.Product.ProductId == productid);

            if (cartItem != null)
            {
                cartItem.Quantity++;
            }
            else
            {
                var productToAdd = allProducts.Single(x => x.ProductId == productid);
                if (productToAdd != null)
                {
                    var newCartItem = new CartItem()
                    {
                        Product    = productToAdd,
                        Quantity   = 1,
                        TotalPrice = productToAdd.Price
                    };

                    cart.Add(newCartItem);
                }
            }

            _session.Set(CartSessionKey, cart);
        }
Exemplo n.º 3
0
        public ActionResult Remove(int id)
        {
            var     productWrapper = new ProductWrapper();
            var     getAllProducts = productWrapper.GetAllProducts();
            Product product        = getAllProducts.Single(x => x.ProductId == id);

            return(View(product));
        }
Exemplo n.º 4
0
        public ActionResult Index()
        {
            var productWrapper = new ProductWrapper();
            var getAllProducts = productWrapper.GetAllProducts();
            //var getAllCategories = productWrapper.GetAllCategories();
            List <Product> listProducts = new List <Product>();

            listProducts = getAllProducts;

            //ProductViewModel productVM = new ProductViewModel() { ProductList = getAllProducts, ProductCategory = getAllCategories };
            return(View(listProducts));
        }