public ActionResult GetProduct(string id, string keyword) { var listProduct = new SanPhamDao().getListSanPham(); var model = new List <ProductModel>(); var ctCTKM = new SanPhamDao().getListctCTKM(id); foreach (var item in listProduct) { var check = false; var temp = ctCTKM.Where(x => x.MASANPHAM == item.MASANPHAM).FirstOrDefault(); if (temp != null) { check = true; } model.Add(new ProductModel() { MaSanPham = item.MASANPHAM, TenSanPham = item.TENSANPHAM, select = check }); } if (string.IsNullOrEmpty(keyword)) { return(Json(model, JsonRequestBehavior.AllowGet)); } else { return(Json(model.Where(x => x.TenSanPham.Contains(keyword) || x.MaSanPham.Contains(keyword)), JsonRequestBehavior.AllowGet)); } }