public ActionResult LotList(int?page, LotSearchViewModel search) { int actualPage = page ?? 1; ViewBag.IsAdminOrModerator = false; IEnumerable <LotEntity> lots; if ((UserViewModel != null)) { ViewBag.IsAdminOrModerator = _customAuthentication.CheckUserInRoles(UserViewModel.ToUserEntity(), "Admin,Moderator"); } if (string.IsNullOrEmpty(search?.SearchString)) { lots = _lotService.GetAllLots(); } else { if (search.SearchInName) { lots = _lotService.GetLotsContainingStringInName(search.SearchString); } else { lots = _lotService.GetLotsContainingStringInDescription(search.SearchString); } } var pager = PagerViewModelCreator <LotViewModel> .GetPagerViewModel(lots.Select(x => x.ToLotViewModel()), actualPage, ItemsPerPage); ViewBag.SearchString = search?.SearchString; ViewBag.SearchInName = search?.SearchInName ?? true; return(PartialView(pager)); }