public ActionResult DeleteProduct(int productID) { var spBLL = new SANPHAMBLL(); spBLL.Delete(productID); return(Redirect("/Admin/ManagerProduct/Index")); }
// GET: Product public ActionResult Index()//Trả về view các sản phẩm mới nhất { var sanpham = new SANPHAMBLL(); ViewBag.Products = sanpham.ListProduct(9); return(View()); }
// GET: Admin/ManagerProduct public ActionResult Index(int page = 1, int pageSize = 5) { var spBLL = new SANPHAMBLL(); var model = spBLL.ListALL(page, pageSize); return(View(model)); }
public ActionResult Index() { var sanpham = new SANPHAMBLL(); ViewBag.Products = sanpham.ListProduct(6); return(View()); }
public ActionResult Category(int id)//Trả về view những sản phẩm của danh mục đã chọn { var category = new DANHMUCBLL().ViewDetail(id); var sanpham = new SANPHAMBLL(); ViewBag.ProductsID = sanpham.ListProductID(id); return(View(category)); }
public ActionResult Detail(int id)//Trả về view chi tiết sản phẩm { var product = new SANPHAMBLL().ViewDetail(id); var sanpham = new SANPHAMBLL(); ViewBag.ProductsID = sanpham.ListProductIDCount(product.CategoryID.Value, 3); ViewBag.Category = new DANHMUCBLL().ViewDetail(product.CategoryID.Value); return(View(product)); }
public ActionResult EditProduct(string Id, string NamePd, string Description, string Price, string danhmuc, string ImageName, string MetaTitle) { SANPHAM sp = new SANPHAM(); sp.Id = Convert.ToInt32(Id); sp.Name = NamePd; sp.Description = Description; sp.Price = Convert.ToInt32(Price); sp.CategoryName = danhmuc; sp.ImageName = ImageName; sp.MetaTitle = MetaTitle; var update = new SANPHAMBLL().Update(sp); return(Redirect("/Admin/ManagerProduct/Index")); }
public ActionResult AddNewProduct(string NamePd, string Description, string Price, string danhmuc, string ImageName, string MetaTitle) { var newproduct = new SANPHAM(); newproduct.CategoryID = new DANHMUCBLL().GetIDByName(danhmuc); newproduct.Name = NamePd; newproduct.Description = Description; newproduct.Price = Convert.ToInt32(Price); newproduct.CategoryName = danhmuc; newproduct.ImageName = ImageName; newproduct.MetaTitle = MetaTitle; newproduct.CreateDays = DateTime.Now; var insert = new SANPHAMBLL().Insert(newproduct); return(RedirectToAction("Index")); }
public ActionResult AddItem(int productID, int quantity)//Thêm giỏ hàng { var product = new SANPHAMBLL().ViewDetail(productID); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.Id == productID)) //Nếu tốn tại ID sản phẩm trong giỏ hàng { foreach (var item in list) { if (item.Product.Id == productID) { item.Quantity += quantity; // Số lượng +1 } } } else { var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } //Gán vào session Session[CartSession] = list; } else { // Tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); //Gán vào session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult UpdateItem(int productID, int soluong) { var product = new SANPHAMBLL().ViewDetail(productID); var cart = Session[CartSession]; var list = (List <CartItem>)cart; if (cart != null) { if (list.Exists(x => x.Product.Id == productID))//tồn tại sp trong giỏ hàng { foreach (var item in list) { if (item.Product.Id == productID) { item.Quantity = soluong; } } } Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult DeleteItem(int productID)//Xóa giỏ hàng { var product = new SANPHAMBLL().ViewDetail(productID); var cart = Session[CartSession]; var list = (List <CartItem>)cart; if (cart != null) { if (list.Exists(x => x.Product.Id == productID))//tồn tại sp trong giỏ hàng { foreach (var item in list) { if (item.Product.Id == productID) { list.RemoveAt(list.IndexOf(item)); break; } } } Session[CartSession] = list; } return(RedirectToAction("Index")); }