public GetByParentPageId ( int parentPageId, string includes = null ) : IOrderedQueryable |
||
parentPageId | int | The Id of the Parent |
includes | string | The includes. |
Результат | IOrderedQueryable |
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click( object sender, EventArgs e ) { Site site; if ( Page.IsValid ) { var rockContext = new RockContext(); SiteService siteService = new SiteService( rockContext ); SiteDomainService siteDomainService = new SiteDomainService( rockContext ); bool newSite = false; int siteId = int.Parse( hfSiteId.Value ); if ( siteId == 0 ) { newSite = true; site = new Rock.Model.Site(); siteService.Add( site ); } else { site = siteService.Get( siteId ); } site.Name = tbSiteName.Text; site.Description = tbDescription.Text; site.Theme = ddlTheme.Text; site.DefaultPageId = ppDefaultPage.PageId; site.DefaultPageRouteId = ppDefaultPage.PageRouteId; site.LoginPageId = ppLoginPage.PageId; site.LoginPageRouteId = ppLoginPage.PageRouteId; site.CommunicationPageId = ppCommunicationPage.PageId; site.CommunicationPageRouteId = ppCommunicationPage.PageRouteId; site.RegistrationPageId = ppRegistrationPage.PageId; site.RegistrationPageRouteId = ppRegistrationPage.PageRouteId; site.PageNotFoundPageId = ppPageNotFoundPage.PageId; site.PageNotFoundPageRouteId = ppPageNotFoundPage.PageRouteId; site.ErrorPage = tbErrorPage.Text; site.GoogleAnalyticsCode = tbGoogleAnalytics.Text; site.FacebookAppId = tbFacebookAppId.Text; site.FacebookAppSecret = tbFacebookAppSecret.Text; var currentDomains = tbSiteDomains.Text.SplitDelimitedValues().ToList<string>(); site.SiteDomains = site.SiteDomains ?? new List<SiteDomain>(); // Remove any deleted domains foreach ( var domain in site.SiteDomains.Where( w => !currentDomains.Contains( w.Domain ) ).ToList() ) { site.SiteDomains.Remove( domain ); siteDomainService.Delete( domain ); } foreach ( string domain in currentDomains ) { SiteDomain sd = site.SiteDomains.Where( d => d.Domain == domain ).FirstOrDefault(); if ( sd == null ) { sd = new SiteDomain(); sd.Domain = domain; sd.Guid = Guid.NewGuid(); site.SiteDomains.Add( sd ); } } if ( !site.DefaultPageId.HasValue && !newSite ) { ppDefaultPage.ShowErrorMessage( "Default Page is required." ); return; } if ( !site.IsValid ) { // Controls will render the error messages return; } rockContext.WrapTransaction( () => { rockContext.SaveChanges(); if ( newSite ) { Rock.Security.Authorization.CopyAuthorization( RockPage.Layout.Site, site, rockContext ); } } ); SiteCache.Flush( site.Id ); // Create the default page is this is a new site if ( !site.DefaultPageId.HasValue && newSite ) { var siteCache = SiteCache.Read( site.Id ); // Create the layouts for the site, and find the first one LayoutService.RegisterLayouts( Request.MapPath( "~" ), siteCache ); var layoutService = new LayoutService( rockContext ); var layouts = layoutService.GetBySiteId( siteCache.Id ); Layout layout = layouts.FirstOrDefault( l => l.FileName.Equals( "FullWidth", StringComparison.OrdinalIgnoreCase ) ); if ( layout == null ) { layout = layouts.FirstOrDefault(); } if ( layout != null ) { var pageService = new PageService( rockContext ); var page = new Page(); page.LayoutId = layout.Id; page.PageTitle = siteCache.Name + " Home Page"; page.InternalName = page.PageTitle; page.BrowserTitle = page.PageTitle; page.EnableViewState = true; page.IncludeAdminFooter = true; page.MenuDisplayChildPages = true; var lastPage = pageService.GetByParentPageId( null ). OrderByDescending( b => b.Order ).FirstOrDefault(); page.Order = lastPage != null ? lastPage.Order + 1 : 0; pageService.Add( page ); rockContext.SaveChanges(); site = siteService.Get( siteCache.Id ); site.DefaultPageId = page.Id; rockContext.SaveChanges(); SiteCache.Flush( site.Id ); } } var qryParams = new Dictionary<string, string>(); qryParams["siteId"] = site.Id.ToString(); NavigateToPage( RockPage.Guid, qryParams ); } }
/// <summary> /// Handles the Click event of the lbSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbSave_Click( object sender, EventArgs e ) { if ( Page.IsValid ) { Rock.Model.Page page; var rockContext = new RockContext(); var pageService = new PageService( rockContext ); int pageId = hfPageId.Value.AsInteger(); if ( pageId == 0 ) { page = new Rock.Model.Page(); if ( _page != null ) { page.ParentPageId = _page.Id; page.LayoutId = _page.LayoutId; } else { page.ParentPageId = null; page.LayoutId = PageCache.Read( RockPage.PageId ).LayoutId; } page.PageTitle = dtbPageName.Text; page.BrowserTitle = page.PageTitle; page.EnableViewState = true; page.IncludeAdminFooter = true; page.MenuDisplayChildPages = true; Rock.Model.Page lastPage = pageService.GetByParentPageId( _page.Id ).OrderByDescending( b => b.Order ).FirstOrDefault(); if ( lastPage != null ) { page.Order = lastPage.Order + 1; } else { page.Order = 0; } pageService.Add( page ); } else { page = pageService.Get( pageId ); } page.LayoutId = ddlLayout.SelectedValueAsInt().Value; page.InternalName = dtbPageName.Text; if ( page.IsValid ) { rockContext.SaveChanges(); PageCache.Flush( page.Id ); if ( _page != null ) { Rock.Security.Authorization.CopyAuthorization( _page, page ); _page.FlushChildPages(); } BindGrid(); } rGrid.Visible = true; pnlDetails.Visible = false; } }
void rGrid_GridReorder( object sender, GridReorderEventArgs e ) { int? parentPageId = null; if (_page != null) parentPageId = _page.Id; var rockContext = new RockContext(); var pageService = new PageService( rockContext ); pageService.Reorder( pageService.GetByParentPageId( parentPageId ).ToList(), e.OldIndex, e.NewIndex ); rockContext.SaveChanges(); BindGrid(); }
/// <summary> /// Handles the GridReorder event of the rGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param> protected void rGrid_GridReorder( object sender, GridReorderEventArgs e ) { if ( _page == null ) { return; } var rockContext = new RockContext(); var pageService = new PageService( rockContext ); pageService.Reorder( pageService.GetByParentPageId( _page.Id ).ToList(), e.OldIndex, e.NewIndex ); rockContext.SaveChanges(); Rock.Web.Cache.PageCache.Flush( _page.Id ); _page.FlushChildPages(); BindGrid(); }
void rGrid_GridReorder( object sender, GridReorderEventArgs e ) { int? parentPageId = null; if (_page != null) parentPageId = _page.Id; var pageService = new PageService(); pageService.Reorder( pageService.GetByParentPageId( parentPageId ).ToList(), e.OldIndex, e.NewIndex, CurrentPersonId ); BindGrid(); }