コード例 #1
0
        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);
        }
コード例 #2
0
        // GET: Products
        public ActionResult Index()
        {
            var productService = new ProductLogic();
            var productListVM = new List<ProductListVM>();
            productListVM = productService.GetProductListVM();

            return View(productListVM);
        }
コード例 #3
0
        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");
        }
コード例 #4
0
 // 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);
 }
コード例 #5
0
 public ActionResult DeleteConfirmed(int id)
 {
     var productService = new ProductLogic();
     productService.RemoveProduct(id);
     return RedirectToAction("Index", "StoreManager");
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 // 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);
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 // GET: StoreManager
 public ActionResult Index()
 {
     var productService = new ProductLogic();
     return View(productService.ToList());
 }