public ActionResult Index(PagerParameters pagerParameters, string provider = null, SitemapEntryOrderBy orderBy = SitemapEntryOrderBy.Provider) { var pager = new Pager(_orchardServices.WorkContext.CurrentSite, pagerParameters); var query = _sitemapService.GetEntries(); if (!String.IsNullOrWhiteSpace(provider)) { query = query.Where(x => x.ProviderName == provider); } switch (orderBy) { case SitemapEntryOrderBy.Priority: query = query.OrderByDescending(x => x.Priority); break; case SitemapEntryOrderBy.ChangeFrequency: query = query.OrderBy(x => x.ChangeFrequency); break; case SitemapEntryOrderBy.LastModified: query = query.OrderByDescending(x => x.LastModifiedUtc); break; case SitemapEntryOrderBy.Url: query = query.OrderBy(x => x.Url); break; case SitemapEntryOrderBy.Provider: default: query = query.OrderBy(x => x.ProviderDisplayName); break; } var totalCount = query.Count(); var pageOfEntries = query.Skip(pager.GetStartIndex()).Take(pager.Page * pager.PageSize); var viewModel = new SitemapIndexViewModel { Handlers = _sitemapService.GetHandlers().ToArray(), Entries = pageOfEntries, SelectedProvider = provider, OrderBy = orderBy, Pager = _orchardServices.New.Pager(pager).TotalItemCount(totalCount) }; return(View(viewModel)); }
public static ISitemapProvider GetHandler(this ISitemapService service, string name) { return(service.GetHandlers().SingleOrDefault(x => x.Name == name)); }