// GET: Admin public ActionResult Index() { Product_Bll bll = new Product_Bll(); var result = bll.GetAllProducts(); return(View(result)); }
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 GetProductById(int id) { Product_Bll bll = new Product_Bll(); var result = bll.GetAllProducts().Where(s => s.Category_Id == id); return(PartialView(result)); }
public ActionResult GetAllProduct() { Product_Bll bll = new Product_Bll(); var result = bll.GetAllProducts(); return(PartialView(result)); }
// GET: Product public ActionResult Index() { TempData["editUser"] = string.Empty; TempData["ChangePassword"] = string.Empty; TempData["Contact"] = string.Empty; Product_Bll bll = new Product_Bll(); var result = bll.GetAllProducts(); return(View(result)); }
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 AddProduct(Product product, HttpPostedFileBase ImagePath) { Product_Bll product_Bll = new Product_Bll(); if (ImagePath != null) { ImagePath.SaveAs(Server.MapPath("~/images/" + ImagePath.FileName)); product.Image = "~/images/" + ImagePath.FileName; } else { product.Image = "~/images/item-cart-01.jpg"; } product_Bll.AddProduct(product); return(RedirectToAction("Index")); }
public ActionResult Index() { TempData["Contact"] = string.Empty; ViewBag.order = TempData["order"]; ViewBag.errorLogin = TempData["LoginError"]; ViewBag.register = TempData["rigster"]; ViewBag.profile = TempData["profile"]; TempData["editUser"] = string.Empty; TempData["ChangePassword"] = string.Empty; Product_Bll bll = new Product_Bll(); var result = bll.GetAllProducts(); Category_Bll category_bll = new Category_Bll(); var categoryList = category_bll.GetAllCategories(); ViewBag.categoryList = categoryList; return(View(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")); }