public ActionResult RemoveFromCart(int id) { Cart1.My().RemoveItem(id); //Cart.Instance.RemoveItem(id); return(RedirectToAction("Products")); }
public ActionResult Checkout(FormCollection formValues) { Order order = new Order(); //Prevent against reload page and resend order to system if (/*PizzaShop.Models.Catalog.Cart.Instance.Items.Count() == 0*/ Cart1.My().Items.Count() == 0) { return(RedirectToAction("Products")); } if (TryUpdateModel(order)) { Order NewOrder = Cart1.My().CreateOrder(order); Cart1.My().ClearCart(); //PizzaShop.Models.Catalog.Cart.Instance.ClearCart(); var status = db.orderRepository.GetOrderStatuses().FirstOrDefault(os => os.Name.Equals("Pending")); NewOrder.OrderStatusId = status.OrderStatusId; NewOrder.User = User.Identity.Name; //cost foreach (var item in NewOrder.Items) { var product_cost = db.productRepository.Get(item.ArchivedProductId).Costs; item.Costs = product_cost; } db.orderRepository.Add(NewOrder); db.Save(); return(View("Accepted", NewOrder.OrderId)); } return(View(order)); }
public ActionResult AddToCart(int id, FormCollection form) { Product product = db.productRepository.Get(id); string comment = form["Comment"]; List <ProductOptionValue> options = new List <ProductOptionValue>(); foreach (var option in product.Options) { options.Add(option.Values.FirstOrDefault(v => v.ProductOptionValueId == Convert.ToInt32(form[option.Name]))); } Cart1.My().AddItem(product, options, comment); //Cart.Instance.AddItem(product, options, comment); return(RedirectToAction("Products", new { category = product.Category.Name })); }