private void MigrateShoppingCart(string userName) { var cart = EFCartRepository.GetCart(this.HttpContext); cart.MigrateCart(userName); Session[EFCartRepository.CartSessionKey] = userName; }
public ActionResult CartSummary() { var cart = EFCartRepository.GetCart(this.HttpContext); ViewData["CartCount"] = cart.GetCount(); return(PartialView("CartSummary")); }
public ActionResult AddToCart(int productID, int count, int productAttributeValueID = 0) { // Retrieve the album from the database var product = productRepository.Products.Single(x => x.ProductID == productID); // Add it to the shopping cart var cart = EFCartRepository.GetCart(this.HttpContext); cart.AddToCart(product, count, CodeHelpers.CreateXmlForAttribute(productAttributeValueID)); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }
// // GET: /Cart/ public ActionResult Index() { var cart = EFCartRepository.GetCart(this.HttpContext); var viewModel = new ShoppingCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; return(View(viewModel)); }
public ActionResult RemoveFromCart(int id) { string currentLanguageCode = (System.Web.HttpContext.Current.Session["Language"] == null || System.Web.HttpContext.Current.Session["Language"].ToString() != "en") ? "tr" : "en"; // Remove the item from the cart var cart = EFCartRepository.GetCart(this.HttpContext); // Get the name of the album to display confirmation string productName = cartRepository.Carts.Single(x => x.RecordId == id).Product.ProductTranslations. FirstOrDefault(x => x.Language.LanguageCode == currentLanguageCode).ProductName; // Remove from cart int itemCount = cart.RemoveFromCart(id); // Display the confirmation message var results = new ShoppingCartRemoveViewModel { Message = Server.HtmlEncode(productName) + currentLanguageCode == "en" ? " has been removed from your shopping cart." : "sepetten çıkarıldı.", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }