コード例 #1
0
ファイル: Sites.ascx.cs プロジェクト: jh2mhs8/Rock-ChMS
        /// <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;
            SiteDomain sd;
            bool newSite = false;

            using ( new UnitOfWorkScope() )
            {
                SiteService siteService = new SiteService();
                SiteDomainService siteDomainService = new SiteDomainService();

                int siteId = 0;
                if ( !int.TryParse( hfSiteId.Value, out siteId ) )
                {
                    siteId = 0;
                }

                if ( siteId == 0 )
                {
                    newSite = true;
                    site = new Rock.Model.Site();
                    siteService.Add( site, CurrentPersonId );
                }
                else
                {
                    site = siteService.Get( siteId );
                    foreach ( var domain in site.SiteDomains.ToList() )
                    {
                        siteDomainService.Delete( domain, CurrentPersonId );
                    }

                    site.SiteDomains.Clear();
                }

                site.Name = tbSiteName.Text;
                site.Description = tbDescription.Text;
                site.Theme = ddlTheme.Text;
                site.DefaultPageId = int.Parse( ddlDefaultPage.SelectedValue );

                foreach ( string domain in tbSiteDomains.Text.SplitDelimitedValues() )
                {
                    sd = new SiteDomain();
                    sd.Domain = domain;
                    sd.Guid = Guid.NewGuid();
                    site.SiteDomains.Add( sd );
                }

                site.FaviconUrl = tbFaviconUrl.Text;
                site.AppleTouchIconUrl = tbAppleTouchIconUrl.Text;
                site.FacebookAppId = tbFacebookAppId.Text;
                site.FacebookAppSecret = tbFacebookAppSecret.Text;

                if ( !site.IsValid )
                {
                    // Controls will render the error messages
                    return;
                }

                siteService.Save( site, CurrentPersonId );

                if ( newSite )
                {
                    Rock.Security.Authorization.CopyAuthorization( CurrentPage.Site, site, CurrentPersonId );
                }

                SiteCache.Flush( site.Id );

                BindGrid();

                pnlDetails.Visible = false;
                pnlList.Visible = true;
            }
        }
コード例 #2
0
ファイル: Pages.ascx.cs プロジェクト: pkdevbox/Rock
        protected void rGrid_Delete( object sender, RowEventArgs e )
        {
            using ( new UnitOfWorkScope() )
            {
                var pageService = new PageService();
                var siteService = new SiteService();

                var page = pageService.Get( (int)rGrid.DataKeys[e.RowIndex]["id"] );
                if ( page != null )
                {
                    RockTransactionScope.WrapTransaction( () =>
                    {
                        foreach ( var site in siteService.Queryable() )
                        {
                            bool updateSite = false;
                            if (site.DefaultPageId == page.Id)
                            {
                                site.DefaultPageId = null;
                                site.DefaultPageRouteId = null;
                                updateSite = true;
                            }
                            if (site.LoginPageId == page.Id)
                            {
                                site.LoginPageId = null;
                                site.LoginPageRouteId = null;
                                updateSite = true;
                            }
                            if (site.RegistrationPageId == page.Id)
                            {
                                site.RegistrationPageId = null;
                                site.RegistrationPageRouteId = null;
                                updateSite = true;
                            }

                            if (updateSite)
                            {
                                siteService.Save( site, CurrentPersonId );
                            }
                        }

                        pageService.Delete( page, CurrentPersonId );
                        pageService.Save( page, CurrentPersonId );

                        Rock.Web.Cache.PageCache.Flush( page.Id );

                        if ( _page != null )
                            _page.FlushChildPages();
                    } );
                }
            }

            BindGrid();
        }
コード例 #3
0
ファイル: Sites.ascx.cs プロジェクト: jh2mhs8/Rock-ChMS
        /// <summary>
        /// Handles the Delete event of the gSites control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gSites_Delete( object sender, RowEventArgs e )
        {
            SiteService siteService = new SiteService();
            Site site = siteService.Get( (int)gSites.DataKeys[e.RowIndex]["id"] );
            if ( CurrentBlock != null )
            {
                siteService.Delete( site, CurrentPersonId );
                siteService.Save( site, CurrentPersonId );

                SiteCache.Flush( site.Id );
            }

            BindGrid();
        }
コード例 #4
0
ファイル: SiteList.ascx.cs プロジェクト: pkdevbox/Rock
        /// <summary>
        /// Handles the Delete event of the gSites control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gSites_Delete( object sender, RowEventArgs e )
        {
            RockTransactionScope.WrapTransaction( () =>
            {
                SiteService siteService = new SiteService();
                Site site = siteService.Get( (int)e.RowKeyValue );
                if ( site != null )
                {
                    string errorMessage;
                    if ( !siteService.CanDelete( site, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }
                    
                    siteService.Delete( site, CurrentPersonId );
                    siteService.Save( site, CurrentPersonId );

                    SiteCache.Flush( site.Id );
                }
            } );

            BindGrid();
        }