public ActionResult CapNhatClient_GioHang(int csanphamid, FormCollection f) { List <Client_GioHang> listClient_GioHang = LayClient_GioHang(); Client_GioHang sanpham = listClient_GioHang.SingleOrDefault(n => n.cSanPhamId == csanphamid); if (sanpham != null) { sanpham.cSoLuong = int.Parse(f["txtSoLuong"].ToString()); } return(RedirectToAction("Client_GioHang")); }
public ActionResult XoaClient_GioHang(int csanphamid) { //Lấy giỏ hànng từ session List <Client_GioHang> listGioHang = LayClient_GioHang(); Client_GioHang sanpham = listGioHang.SingleOrDefault(n => n.cSanPhamId == csanphamid); if (sanpham != null) { listGioHang.RemoveAll(n => n.cSanPhamId == csanphamid); return(RedirectToAction("Client_GioHang")); } if (listGioHang.Count == 0) { return(RedirectToAction("Index", "Client_TrangChu")); } return(RedirectToAction("Client_GioHang")); }
public ActionResult ThemClient_GioHang(int cSanPhamId, string strURL) { List <Client_GioHang> listClient_GioHang = LayClient_GioHang(); Client_GioHang sanpham = listClient_GioHang.Find(n => n.cSanPhamId == cSanPhamId); if (sanpham == null) { sanpham = new Client_GioHang(cSanPhamId); listClient_GioHang.Add(sanpham); ViewBag.message = "Them Thanh Cong"; return(Redirect(strURL)); } else { sanpham.cSoLuong++; return(Redirect(strURL)); } }