public ActionResult Search(string tagName, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var tag = _tagService.GetTagByName(tagName); if (tag == null) { return RedirectToAction("Index"); } var taggedItems = _tagService.GetTaggedContentItems(tag.Id, pager.GetStartIndex(), pager.PageSize).ToList(); var tagShapes = taggedItems.Select(item => _contentManager.BuildDisplay(item, "Summary")); var list = Shape.List(); list.AddRange(tagShapes); var totalItemCount = _tagService.GetTaggedContentItemCount(tag.Id); var viewModel = new TagsSearchViewModel { TagName = tag.TagName, List = list, Pager = Shape.Pager(pager).TotalItemCount(totalItemCount) }; return View(viewModel); }
public ActionResult Search(string tagName) { try { var tag = _tagService.GetTagByName(tagName); var items = _tagService.GetTaggedContentItems(tag.Id).Select( ic => _contentManager.BuildDisplayModel(ic, "SummaryForSearch")); var viewModel = new TagsSearchViewModel { TagName = tag.TagName, Items = items.ToList() }; return View(viewModel); } catch (Exception exception) { _notifier.Error(T("Retrieving tagged items failed: " + exception.Message)); return RedirectToAction("Index"); } }