public ActionResult ThemSanPham(ThemSanPhamGioHangVM vm) { rd = new Random(); try { vuong_cms_context __db = new vuong_cms_context(); var sanpham = __db.Product.Find(vm.SanPhamId); CTGioHang ct = new CTGioHang(); ct.SanPhamId = vm.SanPhamId; ct.TenSanPham = sanpham.ProductName; ct.HinhAnh = sanpham.ThumbnailImage; ct.SoLuong = vm.SoLuong; ct.Link = Url.Action("Detail", "SanPham", new { id = sanpham.Id, seo_title = sanpham.ProductName.URLFriendly() }); GioHang.ThemSanPham(ct); } catch (Exception ex) { return(Content("Lỗi: " + ex.Message)); } return(RedirectToAction("Index")); }