Пример #1
0
 public RedirectToRouteResult RemoveFromCart(int productId, string returnUrl)
 {
     SVTrade.Models.Product product = repository.Products
                                      .FirstOrDefault(p => p.productID == productId);
     if (product != null)
     {
         GetCart().RemoveLine(product);
     }
     return(RedirectToAction("Mapping", new { returnUrl }));
 }
Пример #2
0
 public RedirectToRouteResult AddToCart(int productId, string returnUrl, int pluser = 0)
 {
     SVTrade.Models.Product product = repository.Products
                                      .FirstOrDefault(p => p.productID == productId);
     if (product != null)
     {
         GetCart().AddItem(product, 1, pluser);
     }
     return(RedirectToAction("Mapping", new { returnUrl }));
 }
Пример #3
0
        public RedirectToRouteResult AddItem(SVTrade.Models.Product product, int?pluser, string returnUrl)
        {
            CartLine line = Cart.lineCollection
                            .Where(p => p.Product.productID == product.productID)
                            .FirstOrDefault();

            if (line == null)
            {
            }
            else
            if (pluser > 0)
            {
                line.Product.amount = Convert.ToInt16(pluser);
            }
            return(RedirectToAction("Mapping", new { returnUrl }));
        }
Пример #4
0
 public void SaveProduct(Product product)
 {
     if (product.productID == 0)
     {
         _db.Products.Add(product);
     }
     else
     {
         var dbEntry = _db.Products.Find(product.productID);
         if (dbEntry != null)
         {
             dbEntry.name = product.name;
             dbEntry.productCategoryID = product.productCategoryID;
             dbEntry.imageURL = product.imageURL;
             dbEntry.amount = product.amount;
             dbEntry.price = product.price;
             dbEntry.description = product.description;
             dbEntry.userID = product.userID;
         }
     }
     _db.SaveChanges();
 }
Пример #5
0
        public ActionResult EditProduct(Product product)
        {
            if (ModelState.IsValid)
            {
                repository.SaveProduct(product);
                TempData["message"] = string.Format("Товар {0} було збережено!", product.title);

                return RedirectToAction("ProductsList");
            }
            else
            {
                return View(product);
            }
        }