public ActionResult BasketSummary() { ShoppingBasketHelper helper = new ShoppingBasketHelper(); ViewData["BasketCount"] = helper.GetBasketCount(); return(PartialView("BasketSummary")); }
public ActionResult ClearCart() { ShoppingBasketHelper helper = new ShoppingBasketHelper(); helper.ClearBasket(); return(RedirectToAction("Index")); }
public ActionResult Complete(int orderId, decimal orderTotal) { ShoppingBasketHelper helper = new ShoppingBasketHelper(); helper.endShoppingSession(); ViewBag.OrderTotal = orderTotal.ToString(); return(View(orderId)); }
public ActionResult AddToCart(string id, string quantity) { ShoppingBasketHelper helper = new ShoppingBasketHelper(); int intId = Convert.ToInt32(id); int intQty = Convert.ToInt32(quantity); var addedPizza = db.Items.Single(item => item.ItemId == intId); helper.AddToBasket(addedPizza, intQty); return(RedirectToAction("Index")); }
public ActionResult Index() { ShoppingBasketHelper helper = new ShoppingBasketHelper(); if (helper.CheckBasket()) { return(View()); } else { return(RedirectToAction("Index", "PizzaBasket")); } }
// // GET: /PizzaBasket/ public ActionResult Index() { ShoppingBasketHelper helper = new ShoppingBasketHelper(); // Set up our ViewModel var viewModel = new ShoppingBasketViewModel { BasketItems = helper.GetCartItems(), BasketTotal = helper.GetTotal() }; // Return the view return(View(viewModel)); }
public ActionResult Index(FormCollection values) { var order = new Order(); TryUpdateModel(order); try { ShoppingBasketHelper helper = new ShoppingBasketHelper(); decimal priceAfterDiscount = helper.getDiscountedPrice(values["PromoCode"], helper.GetTotal()); order.OrderDate = DateTime.Now; order.OrderStatus = "Undelivered"; order.Total = priceAfterDiscount; db.Orders.Add(order); List <BasketItem> currentItem = helper.GetCartItems(); foreach (BasketItem element in currentItem.ToList()) { var orderDetail = new OrderDetail { ItemId = element.ItemId, OrderId = order.OrderId, UnitPrice = element.Item.ItemPrice, Quantity = element.Count }; db.OrderDetails.Add(orderDetail); } db.SaveChanges(); return(RedirectToAction("Complete", new { orderId = order.OrderId, orderTotal = order.Total })); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } return(View(order)); } }
public ActionResult RemoveFromCart(int id) { ShoppingBasketHelper helper = new ShoppingBasketHelper(); // Get the name of the album to display confirmation string itemName = db.Items .Single(item => item.ItemId == id).ItemName; // Remove from cart int itemCount = helper.RemoveFromBasket(id); // Display the confirmation message var results = new ShoppingBasketRemoveViewModel { Message = Server.HtmlEncode(itemName) + " has been removed from your shopping cart.", BasketTotal = helper.GetTotal(), BasketCount = helper.GetBasketCount(), DeleteId = id }; return(RedirectToAction("Index")); }