public ActionResult Popular(string query, int?pageNumber, int?pageSize) { ViewBag.NavigationKey = "popular"; ViewBag.Query = query; if (pageNumber == null || pageNumber < 1) { pageNumber = 1; } if (pageSize == null) { pageSize = 24; } if (pageSize > 100) { pageSize = 100; } if (pageSize < 1) { pageSize = 1; } var subs = _subDao.GetAllSubs(query, sortBy: SubsSortBy.Subscribers, nsfw: _userContext.CurrentNsfw, skip: ((pageNumber - 1) * pageSize), take: pageSize); return(View("List", new PagedList <SubWrapped>(_subWrapper.Wrap(subs, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, subs.HasMore))); }
public ActionResult Index(string query) { var subscribedSubs = _contextService.GetSubscribedSubNames(); var allSubs = _subDao.GetAllSubs(query).Select(x => { var model = _mapper.Map <Sub, SubModel>(x); if (subscribedSubs.Contains(model.Name)) { model.IsSubscribed = true; } return(model); }).ToList(); ViewBag.Query = query; return(View(allSubs)); }