public ActionResult RemoveFromCart(int id) { var cart = ShoppingCartLogic.GetCart(this.HttpContext); var shoppingCart = new ShoppingCartLogic(); int productId = shoppingCart.GetCartItemProductId(id); var productService = new ProductLogic(); Product productToRemove = productService.FindProduct(productId); int itemCount = cart.RemoveFromCart(id); var removeViewModel = new ShoppingCartRemoveVM { Message = Server.HtmlEncode(productToRemove.Name) + " has been removed from your shopping cart.", CartCount = cart.GetCount(), CartSubTotal = cart.GetSubtotal(), CartSalesTax = cart.GetSalesTax(), CartTotal = cart.GetTotal(), ItemCount = itemCount, DeleteId = id, }; return Json(removeViewModel); }
// GET: Products public ActionResult Index() { var productService = new ProductLogic(); var productListVM = new List<ProductListVM>(); productListVM = productService.GetProductListVM(); return View(productListVM); }
public ActionResult AddToCart(int id) { var productService = new ProductLogic(); var productAdded = productService.FindProduct(id); ShoppingCartLogic cart = ShoppingCartLogic.GetCart(this.HttpContext); cart.AddToCart(productAdded); return RedirectToAction("Index"); }
// GET: Products/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var productService = new ProductLogic(); Product product = productService.FindProduct(id); if (product == null) { return HttpNotFound(); } return View(product); }
public ActionResult DeleteConfirmed(int id) { var productService = new ProductLogic(); productService.RemoveProduct(id); return RedirectToAction("Index", "StoreManager"); }
public ActionResult ProductEdit([Bind(Include = "ProductId,Name,Description,Quantity,Price,Cost,PurchaseDate,SoldDate")] Product product) { if (ModelState.IsValid) { var productService = new ProductLogic(); productService.EditProduct(product); return RedirectToAction("Index"); } return View(product); }
// GET: StoreManager/Product/Edit/5 public ActionResult ProductEdit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var productService = new ProductLogic(); Product product = productService.FindProduct(id); if (product == null) { return HttpNotFound(); } var categoryList = new CategoryLogic(); ViewBag.CategoryId = categoryList.SetCategoryViewBag(id); return View(product); }
public ActionResult ProductCreate([Bind(Include = "ProductId,Name,Description,CategoryId,Quantity,Price,Cost,PurchaseDate,SoldDate")] Product product) { if (ModelState.IsValid) { var newProduct = new ProductLogic(); newProduct.CreateNewProduct(product); return RedirectToAction("Index", "StoreManager"); } return View(product); }
// GET: StoreManager public ActionResult Index() { var productService = new ProductLogic(); return View(productService.ToList()); }