public IActionResult AddToCart(int id) { var product = _productService.GetById(id); var cart = _cartSessionHelper.GetCart("cart"); _cartService.AddToCart(product, cart); _cartSessionHelper.SetCart("cart", cart); return(RedirectToAction("Index", "Product")); }
public IActionResult AddToCart(int productId) { Product product = _productService.GetById(productId); var cart = _cartSessionHelper.GetCart("cart"); _cartService.AddToCart(cart, product); _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")); }
public IActionResult AddToCart(int drinkId) { var drink = _drinkService.GetDrinkById(drinkId); var cart = _cartSessionHelper.GetCart(CartKey); if (drink != null) { _cartService.AddToCart(cart, drink, 1); } _cartSessionHelper.SetCart(CartKey, cart); return(RedirectToAction("Index")); }
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")); }
//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")); }
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 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")); }
public IActionResult AddToCart(int productId) { Product product = _productService.GetById(productId); var cart = _cartSessionHelper.GetCart("cart"); _cardService.AddToCart(cart, product); _cartSessionHelper.SetCart("cart", cart); string redirectUrl = "/Product?categoryId=" + product.CategoryID.ToString(); TempData.Add("message", product.ProductName + " sepete eklendi!"); //return RedirectToAction("Index", "Product","?categoryId="+product.CategoryID.ToString()); return(Redirect(redirectUrl)); }