public void AddItem(Product product, int quantity) { CartLine line = lineCollection .FirstOrDefault(p => p.Product.Id == product.Id); if (line == null) { lineCollection.Add(new CartLine { Product = product, Quantity = quantity }); } else { line.Quantity += quantity; } }
public ActionResult CreateProduct(Product product, HttpPostedFileBase photo) { if (ModelState.IsValid) { if (photo != null) { product.PhotoMimeType = photo.ContentType; product.ProductPhoto = new byte[photo.ContentLength]; photo.InputStream.Read(product.ProductPhoto, 0, photo.ContentLength); } _productService.Insert(product); TempData["message"] = string.Format("{0} has been created", product.Name); return Json( new { success = true }); } ViewBag.Id = new SelectList(_categoryService.GetAll().ToList(), "Id", "Name"); return PartialView("_CreateProduct", product); }
public void RemoveLine(Product product) { lineCollection.RemoveAll(l => l.Product.Id == product.Id); }
public ActionResult EditProduct(Product product, HttpPostedFileBase photo) { if (ModelState.IsValid) { if (photo != null) { product.PhotoMimeType = photo.ContentType; product.ProductPhoto = new byte[photo.ContentLength]; photo.InputStream.Read(product.ProductPhoto, 0, photo.ContentLength); } _productService.Update(product); TempData["message"] = string.Format("{0} has been saved", product.Name); return RedirectToAction("Index"); } return View(product); }
public void Update(Product model) { if (model == null) throw new ArgumentNullException("product"); productRepository.Update(model); }
public void Insert(Product model) { if (model == null) throw new ArgumentNullException("product"); productRepository.Insert(model); }