public override ActionResult Index(PageListBlock currentBlock) { var pages = FindPages(currentBlock); pages = Sort(pages, currentBlock.SortOrder); if (currentBlock.Count > 0) { pages = pages.Take(currentBlock.Count); } var model = new PageListBlockViewModel(currentBlock) { Pages = pages }; ViewData.GetEditHints <PageListBlockViewModel, PageListBlock>() .AddConnection(x => x.Heading, x => x.Heading); return(PartialView("~/Features/Blocks/Views/PageListBlock.cshtml", model)); }
public override IViewComponentResult Invoke(PageListBlock currentBlock) { var pages = FindPages(currentBlock); pages = Sort(pages, currentBlock.SortOrder); if (currentBlock.Count > 0) { pages = pages.Take(currentBlock.Count); } var model = new PageListBlockViewModel(currentBlock) { Pages = pages.Select(x => new PageListPreviewViewModel(x, currentBlock)) }; ViewData.GetEditHints <PageListBlockViewModel, PageListBlock>() .AddConnection(x => x.Heading, x => x.Heading); return(View("~/Features/Blocks/PageListBlock/PageListBlock.cshtml", model)); }
public PageListBlockViewModel CreatePageListBlockViewModel(PageListBlock currentBlock, SitePage currentPage) { var pages = FindPages(currentBlock); var items = new List <PageListBlockItemViewModel>(); pages = Sort(pages, currentBlock.SortOrder); if (currentBlock.Count > 0) { pages = pages.Take(currentBlock.Count); foreach (var page in pages) { items.Add(new PageListBlockItemViewModel(page)); } } var model = new PageListBlockViewModel(currentPage, currentBlock) { Pages = items }; return(model); }