public ActionResult AddToCart(int id) { Product_Bll bll = new Product_Bll(); if (Session["CurrentUser"] != null) { if (Session["cart"] == null) { List <ItemCart> list = new List <ItemCart>(); list.Add(new ItemCart { Product = bll.GetProductById(id), Quantity = 1 }); Session["cart"] = list; } else { List <ItemCart> list = Session["cart"] as List <ItemCart>; int index = isExist(id); if (index != -1) { list[index].Quantity++; } else { list.Add(new ItemCart { Product = bll.GetProductById(id), Quantity = 1 }); } Session["cart"] = list; } } return(RedirectToAction("Index")); }
public ActionResult EditProduct(int id) { Product_Bll product_Bll = new Product_Bll(); var result = product_Bll.GetProductById(id); Category_Bll category_Bll = new Category_Bll(); var categoryList = category_Bll.GetAllCategories(); SelectList items = new SelectList(categoryList, "Id", "Name"); ViewBag.category = items; return(PartialView(result)); }
public ActionResult EditProduct(Product product, HttpPostedFileBase ImagePath) { Product_Bll product_Bll = new Product_Bll(); Product oldproduct = product_Bll.GetProductById(product.Id); if (ImagePath != null) { ImagePath.SaveAs(Server.MapPath("~/images/" + ImagePath.FileName)); product.Image = "~/images/" + ImagePath.FileName; } else { product.Image = oldproduct.Image; } product_Bll.EditProduct(product); return(RedirectToAction("Index")); }