public async Task <IActionResult> AddToShoppingCartDisplayProducts(DisplayProductsViewModel model) { var selectedProduct = _productRepository.GetProduct(model.Id); var user = await _userManager.GetUserAsync(HttpContext.User); if (selectedProduct != null) { _shoppingCart.AddToCart(selectedProduct, model.Quantity, user.Id); } return(RedirectToAction("DisplayProducts", "Product", new { id = 1 })); }
public RedirectToActionResult AddToShoppingCart(int pieId) { var existingPies = _pieRepository.Pies.FirstOrDefault(x => x.PieId == pieId); if (existingPies != null) { _shoppingCart.AddToCart(existingPies, 1); TempData["ItemAdded"] = "Success"; } return(RedirectToAction("Index")); }
public ActionResult AddToCart(int id, int quantity) { var product = dal.GetProduct(id); ShoppingCartModel cart = GetActiveShoppingCart(); cart.AddToCart(product, quantity); Session["Shopping_Cart"] = cart; return(RedirectToAction("ViewCart", cart)); }