public IActionResult Index()
        {
            var model = new CartListViewModel
            {
                Cart = _cartSessionHelper.GetCart("cart")
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var cart  = _cartSessionHelper.GetCart(CartKey);
            var model = new CartListViewModel()
            {
                Cart = cart
            };

            return(View(model));
        }
        public IActionResult AddToCart(int productId)
        {
            Product product = _productService.GetById(productId);
            var     cart    = _cartSessionHelper.GetCart("cart");

            _cartService.AddToCart(product, cart);
            _cartSessionHelper.SetCart("cart", cart);
            TempData.Add("message", product.ProductName + " sepete eklendi!");
            return(RedirectToAction("Index", "Product"));
        }
        public IActionResult AddToCart(int productId)
        {
            var product = _productRepo.GetById(productId);
            var cart    = _cartSessionHelper.GetCart("cart");

            _cartService.AddToCart(cart, product);

            _cartSessionHelper.SetCart("cart", cart);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 5
0
        public IActionResult AddToCart(int productId)
        {
            //ürünü çek
            Product product = _productService.GetById(productId);

            var cart = _cartSessionHelper.GetCart("cart");

            _cardService.AddToCart(cart, product);
            _cartSessionHelper.SetCart("cart", cart);
            TempData.Add("message", product.ProductName + "item is added to basket");
            return(RedirectToAction($"Index", $"Product"));
        }
        public IActionResult AddToCart(int productId)
        {
            //Get Product
            Product product = _productService.GetById(productId);
            var     cart    = _cartSessionHelper.GetCart("cart");

            _cartService.AddToCart(cart, product);
            _cartSessionHelper.SetCart("cart", cart);

            TempData.Add("message", product.ProductName + "added to your cart.");

            return(RedirectToAction("Index", "Product"));
        }
Esempio n. 7
0
        //sepete ekle butonu için

        public IActionResult AddToCart(int productid)
        {
            //öncelikle idsi verilen ürünü veritabanından cekmemiz gerekiyor
            Product product = _productService.GetById(productid);
            //sonra sessiondan sepeti çekmem gerekiyor öünkü oraya eklicem
            var cart = _cartSessionHelper.GetCart(key: "cart");

            //sepete ürünü eklemem gerekiyor
            _cartService.AddToCart(cart, product);
            //sepeti sessiona geri eklememiz gerekiyor.
            _cartSessionHelper.SetCart(key: "cart", cart);
            //ProductContorllerdaki index aksiyonuna gönder.
            TempData.Add("message", product.ProductName + " sepette eklendi!");
            return(RedirectToAction("Index", controllerName: "Product"));
        }
Esempio n. 8
0
        public IActionResult AddToCart(int productId)
        {
            Product product = productService.GetById(productId);

            var cart = cartSessionHelper.GetCart("cart");

            cartService.AddToCart(cart, product);

            cartSessionHelper.SetCart(key: "cart", cart);

            TempData.Add("message", product.ProductName + " sepete eklendi.");

            return(Redirect(@"/product/index?category=" + product.CategoryId));

            //return RedirectToAction("Index", "Product");
        }
        public IActionResult AddToCart(int productId)
        {   // temel session implementasyonu
            //HttpContext.Session.SetInt32("data", 1);
            //var aa= HttpContext.Session.GetInt32("data");
            //HttpContext.Session.SetString("data2", "1");
            //var bb = HttpContext.Session.GetString("data2");



            Product product = _productService.GetById(productId).Data;
            var     cart    = _cartSessionHelper.GetCart("cart");

            _cartService.AddToCart(cart, product);
            _cartSessionHelper.SetCart("cart", cart);
            ShowTimerMessage("Sepete eklendi", MessageType.Success);
            return(RedirectToAction("Index", "Product"));
        }
        public ViewViewComponentResult Invoke()
        {
            var model = new CartListViewModel
            {
                Cart = _cartSessionHelper.GetCart("cart")
            };

            return(View(model));
        }
Esempio n. 11
0
        public ViewViewComponentResult Invoke()
        {
            var model = new CartListViewModel()
            {
                Cart = _cartSessionHelper.GetCart(CartController.CartKey)
            };

            return(View(model));
        }
Esempio n. 12
0
        public IActionResult CheckOut(Order order)
        {
            var cart = _cartSessionHelper.GetCart(CartController.CartKey);

            order.OrderTotal = cart.TotalPrice;
            if (ModelState.IsValid)
            {
                _orderService.TransactionalOperation(order, cart);
                _cartSessionHelper.Clear();
                return(RedirectToAction("CheckOutComplete"));
            }
            return(View(order));
        }
Esempio n. 13
0
        public IActionResult AddToCart(int productId)
        {
            //ürünü çek
            var dataResult = _productService.GetById(productId);

            ProductDetailDto productDetailDto = dataResult.Data;

            var cart = _cartSessionHelper.GetCart("cart");

            _cartService.AddToCart(cart, productDetailDto.Product);

            _cartSessionHelper.SetCart("cart", cart);
            TempData.Remove(TempDataTypes.AddedToCart);
            TempData.Add(TempDataTypes.AddedToCart, productDetailDto.Product.ProductName + " sepete eklendi!");

            return(RedirectToAction("Index", "Product"));
        }