public bool UpdateQuantityInCart(ProductCartModel productCartModel)
        {
            var productCartEntity = new ProductCartDTO();
            var productCartRepository = new ProductCartRepository();

            AutoMapper.Mapper.Map(productCartModel, productCartEntity);
            var status = productCartRepository.UpdateQuantityInCart(productCartEntity);

            return status;
        }
        public bool InsertProductCart(ProductCartModel productCartModel)
        {
            var productCartEntity = new ProductCartDTO();
            var productCartRepository = new ProductCartRepository();

            AutoMapper.Mapper.Map(productCartModel, productCartEntity);
            bool status = productCartRepository.InsertProductCart(productCartEntity);

            return status;
        }
Exemplo n.º 3
0
        public ActionResult ShoppingCart(ProductCartModel productCart)
        {
            ViewData["Data"] = null;
            ShoppingCartModel cart = new ShoppingCartModel();
            cart.ShoppingCartProductPrice = Convert.ToDecimal(productCart.ProductCartPrice);
            cart.ShoppingCartProductKId = Convert.ToInt32(productCart.ProductCartProductKId);
            cart.ShoppingCartQuantity = Convert.ToInt32(productCart.ProductCartQuantity);
            cart.ShoppingCartId = GetShoppingCartId();
            bool status = false;
            status = ShoppingCartService.InsertProductShoppingCart(cart);

            if (status)
            {
                ViewData["Data"] = ToJSON(ShoppingCartService.GetShoppingCartIteim(GetShoppingCartId()));
                ViewData["AddToCartItems"] = ShoppingCartService.CountShoppingCartItems(GetShoppingCartId());
            }
            return View();
        }
Exemplo n.º 4
0
        public ActionResult ShoppingCart(ProductCartModel productCart)
        {
            IList<ProductCartModel> productCartModelList;

            shoppingCartId = base.GetShoppingCartId();

            if (productCart.ProductId > 0)
            {
                productCartModelList = productCartManager.GetCartItems(shoppingCartId);
                ProductCartModel productCartModel = productCartModelList.FirstOrDefault(x => x.ProductId == productCart.ProductId);
                if (productCartModel == null)
                {
                    productCart.CartId = shoppingCartId;
                    bool status = productCartManager.InsertProductCart(productCart);
                }
            }

            productCartModelList = productCartManager.GetCartItems(shoppingCartId);
            ViewBag.ItemsCount = productCartManager.CountCartItems(shoppingCartId);

            return View(productCartModelList);
        }
Exemplo n.º 5
0
        public ActionResult UpdateQuantityInCart(int productCartId, int quantity)
        {
            shoppingCartId = base.GetShoppingCartId();

            var productCartModel = new ProductCartModel();
            productCartModel.Id = productCartId;
            productCartModel.Quantity = quantity;

            var productCartManager = new ProductCartManager();
            productCartManager.UpdateQuantityInCart(productCartModel);
            return RedirectToAction("ShoppingCart", productCartManager.GetCartItems(shoppingCartId).FirstOrDefault());
        }