public ActionResult Index(int?pageIndex, int?pageSize, string searchString, bool active = true) { pageIndex = (pageIndex ?? 1); pageSize = pageSize ?? GlobalConfigs.DEFAULT_PAGESIZE; var model = new KeViewIndexModel() { PageIndex = pageIndex.Value, PageSize = pageSize.Value }; var listKe = _keService.GetAllHaveJoinTu(); var kes = _keService.GetAllPaged(listKe, pageIndex, pageSize.Value, p => p.TrangThai == active, p => p.OrderByDescending(c => c.NgayTao)); if (!string.IsNullOrEmpty(searchString)) { kes = _keService.GetAllPaged(listKe, pageIndex, pageSize.Value, p => p.Ten.Contains(searchString) && p.TrangThai == active && p.TrangThai == active, p => p.OrderByDescending(c => c.NgayTao)); } model.Paged = kes; model.Items = GetKes(kes.ToList()); ViewBag.Active = active; ViewBag.searchString = searchString; ViewBag.Controller = "Ke"; return(View(model)); }
private IEnumerable <Ke> GetKes() { var listKe = _keService.GetAllHaveJoinTu(); var model = listKe.Where(p => p.TrangThai == true); return(model); }