コード例 #1
0
        public ActionResult Index(int?pageIndex, int?pageSize, string searchString, bool active = true)
        {
            pageIndex = (pageIndex ?? 1);
            pageSize  = pageSize ?? GlobalConfigs.DEFAULT_PAGESIZE;

            var listHop = _hopService.GetAllHaveJoinAll();

            var model = new HopViewIndexModel()
            {
                PageIndex = pageIndex.Value,
                PageSize  = pageSize.Value
            };
            var hops = _hopService.GetAllPaged(listHop, pageIndex, pageSize.Value, p => p.TrangThai == active,
                                               p => p.OrderByDescending(c => c.NgayTao));

            if (!string.IsNullOrEmpty(searchString))
            {
                hops = _hopService.GetAllPaged(listHop, pageIndex, pageSize.Value, p => p.ChuyenDe.Contains(searchString) || p.PhongBan.Ten.Contains(searchString) &&
                                               p.TrangThai == active, p => p.OrderByDescending(c => c.NgayTao));
            }

            model.Paged = hops;
            model.Items = GetHops(hops.ToList());

            ViewBag.Active       = active;
            ViewBag.searchString = searchString;
            ViewBag.Controller   = "Hop";

            return(View(model));
        }