private void MigrateShoppingCart(string userName) { var cart = ShoppingCarrinho.GetCart(this.HttpContext); cart.MigrateCart(userName); Session[ShoppingCarrinho.CartSessionKey] = userName; }
public ActionResult AddressAndPayment(FormCollection values) { var order = new OrdemCliente(); TryUpdateModel(order); try { if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false) { return(View(order)); } else { order.CustomerUserName = User.Identity.Name; order.DateCreated = DateTime.Now; db.CustomerOrders.Add(order); db.SaveChanges(); var cart = ShoppingCarrinho.GetCart(this.HttpContext); cart.CreateOrder(order); db.SaveChanges();//we have received the total amount lets update it return(RedirectToAction("Complete", new { id = order.Id })); } } catch (Exception ex) { ex.InnerException.ToString(); return(View(order)); } }
public ActionResult CartSummary() { var cart = ShoppingCarrinho.GetCart(this.HttpContext); ViewData["CartCount"] = cart.GetCount(); return(PartialView("CartSummary")); }
public ActionResult LogOff() { FormsAuthentication.SignOut(); var cart = ShoppingCarrinho.GetCart(this.HttpContext); cart.EmptyCart(); return(RedirectToAction("Index", "Home")); }
public ActionResult AddToCart(int id) { var addedProduct = db.Products.Single(product => product.Id == id); var cart = ShoppingCarrinho.GetCart(this.HttpContext); cart.AddToCart(addedProduct); return(RedirectToAction("Index")); }
public ActionResult Index() { var cart = ShoppingCarrinho.GetCart(this.HttpContext); var viewModel = new ShoppingCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; return(View(viewModel)); }
public ActionResult RemoveFromCart(int id) { var cart = ShoppingCarrinho.GetCart(this.HttpContext); string productName = db.Carts.FirstOrDefault(item => item.ProductId == id).Product.Name; int itemCount = cart.RemoveFromCart(id); var results = new ShoppingCartRemoveViewModel { Message = Server.HtmlEncode(productName) + " has been removed from your shopping cart", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }