public IActionResult FilterAndSearch(string search, string ploai, string mahang, string filter, int?pagenumber) { float minprice = float.Parse(filter.Substring(filter.IndexOf('đ') + 1, filter.IndexOf(' ') - 1)); float maxprice = float.Parse(filter.Substring(filter.LastIndexOf('đ') + 1)); pageNumber = pagenumber ?? 1; SanPhamBUS sanphambus = new SanPhamBUS(); List <SanPham> list = sanphambus.FilterAndSearch(minprice, maxprice, search, ploai, mahang, pageSize, pageNumber); List <SanPham> tong = sanphambus.FilterAndSearch(minprice, maxprice, search, ploai, mahang); ViewBag.TrangHienTai = pageNumber; ViewBag.TongTrang = TongTrang(tong); ViewBag.TrangThai = "filterandsearch"; ViewBag.Filter = filter; ViewBag.Search = search; if (ploai != null) { ViewBag.PhanLoai = ploai == "Nam" ? "Nam" : "Nu"; } ViewBag.ThuongHieu = mahang; if (ploai != null && ploai != "") { ViewBag.Loai = ploai == "Nam" ? "Nam" : "Nu"; } else { ViewBag.PhanLoai = ploai; } List <HangSanPham> hang = ctx.HangSanPham.ToList(); ViewBag.Hang = hang; return(View("List", list)); }