本文整理汇总了C#中Rock.Model.PageService.GetAllDescendents方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.GetAllDescendents方法的具体用法?C# PageService.GetAllDescendents怎么用?C# PageService.GetAllDescendents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PageService
的用法示例。
在下文中一共展示了PageService.GetAllDescendents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
/// <summary>
/// Returns a list of matching people
/// </summary>
/// <param name="searchterm"></param>
/// <returns></returns>
public override IQueryable<string> Search( string searchterm )
{
var rootPageGuid = GetAttributeValue( "RootPage" ).AsGuid();
var terms = searchterm.Split( ' ' );
var pageServ = new PageService( new RockContext() );
IEnumerable<Page> pages;
var rootPage = pageServ.Get( rootPageGuid );
if ( rootPage != null )
{
pages = pageServ.GetAllDescendents( rootPage.Id );
}
else
{
pages = pageServ.Queryable();
}
return pages.ToList().Where( p => Regex.IsMatch( p.PageTitle, String.Join( "\\w* ", terms.Select( t => Regex.Escape( t ) ) ), RegexOptions.IgnoreCase ) ).Select( p => p.PageTitle ).AsQueryable();
}
示例2: BindPagesGrid
/// <summary>
/// Binds the pages grid.
/// </summary>
protected void BindPagesGrid()
{
pnlPages.Visible = false;
int siteId = PageParameter( "siteId" ).AsInteger() ?? 0;
if ( siteId == 0 )
{
// quit if the siteId can't be determined
return;
}
hfSiteId.SetValue( siteId );
pnlPages.Visible = true;
LayoutService layoutService = new LayoutService();
layoutService.RegisterLayouts( Request.MapPath( "~" ), SiteCache.Read( siteId ), CurrentPersonId );
var layouts = layoutService.Queryable().Where( a => a.SiteId.Equals( siteId ) ).Select( a => a.Id ).ToList();
var siteService = new SiteService();
var pageId = siteService.Get( siteId ).DefaultPageId;
var pageService = new PageService();
var qry = pageService.GetAllDescendents( (int)pageId ).AsQueryable().Where( a => layouts.Contains(a.LayoutId) );
string layoutFilter = gPagesFilter.GetUserPreference( "Layout" );
if ( !string.IsNullOrWhiteSpace( layoutFilter ) && layoutFilter != Rock.Constants.All.Text )
{
qry = qry.Where( a => a.Layout.ToString() == layoutFilter );
}
SortProperty sortProperty = gPages.SortProperty;
if ( sortProperty != null )
{
qry = qry.Sort( sortProperty );
}
else
{
qry = qry.OrderBy( q => q.Id );
}
gPages.DataSource = qry.ToList();
gPages.DataBind();
}