Esempio n. 1
0
        public ActionResult KetQuaTimKiem(FormCollection f, int?page)
        {
            string y = f["txtTimKiem"].ToString();
            //tra ve 1 list co dinh tu khoa
            List <Sach> kqtk = db.Sach.Where(x => x.TenSach.Contains(y)).ToList();

            List <ThongTinSach> thongtin = new SachDao().listSach();

            var e = (from a in thongtin
                     join b in kqtk on a.TenSach equals b.TenSach
                     select a).ToList();

            if (kqtk.Count == 0)
            {
                ViewBag.ThongBao = "Khong tim thay san pham nao";
                return(View(thongtin.OrderBy(n => n.TenSach)));
            }

            return(View(e.OrderBy(n => n.TenSach)));
        }