/// <summary> /// Executes this instance. /// </summary> /// <param name="message"></param> public override void Execute(Message message) { var pageCache = PageCache.Get(message.PageGuid); if (pageCache == null) { return; } var rockContext = new RockContext(); var interactionComponentService = new InteractionComponentService(rockContext); var componentQuery = interactionComponentService.QueryByPage(pageCache); rockContext.BulkUpdate(componentQuery, ic => new InteractionComponent { Name = pageCache.InternalName }); }
/// <summary> /// Handles the DeleteClick event of the mdDeleteModal 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 mdDeleteModal_SaveClick(object sender, EventArgs e) { if (!PageIdBeingDeleted.HasValue) { return; } var rockContext = new RockContext(); var pageService = new PageService(rockContext); var siteService = new SiteService(rockContext); var page = pageService.Get(PageIdBeingDeleted.Value); if (page != null) { string errorMessage = string.Empty; if (!pageService.CanDelete(page, out errorMessage)) { mdDeleteModal.Hide(); mdDeleteWarning.Show(errorMessage, ModalAlertType.Alert); return; } foreach (var site in siteService.Queryable()) { if (site.DefaultPageId == page.Id) { site.DefaultPageId = null; site.DefaultPageRouteId = null; } if (site.LoginPageId == page.Id) { site.LoginPageId = null; site.LoginPageRouteId = null; } if (site.RegistrationPageId == page.Id) { site.RegistrationPageId = null; site.RegistrationPageRouteId = null; } } pageService.Delete(page); if (cbDeleteInteractions.Checked) { var interactionComponentService = new InteractionComponentService(rockContext); var componentQuery = interactionComponentService.QueryByPage(page); interactionComponentService.DeleteRange(componentQuery); } rockContext.SaveChanges(); PageUpdated = true; } mdDeleteModal.Hide(); BindGrid(); }
/// <summary> /// Handles the DeleteClick event of the mdDeleteModal 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 mdDeleteModal_DeleteClick(object sender, EventArgs e) { var rockContext = new RockContext(); var pageService = new PageService(rockContext); var siteService = new SiteService(rockContext); int pageId = hfPageId.Value.AsInteger(); var page = pageService.Get(pageId); if (page != null) { string errorMessage = string.Empty; if (!pageService.CanDelete(page, out errorMessage)) { mdDeleteWarning.Show(errorMessage, ModalAlertType.Alert); return; } foreach (var site in siteService.Queryable()) { if (site.DefaultPageId == page.Id) { site.DefaultPageId = null; site.DefaultPageRouteId = null; } if (site.LoginPageId == page.Id) { site.LoginPageId = null; site.LoginPageRouteId = null; } if (site.RegistrationPageId == page.Id) { site.RegistrationPageId = null; site.RegistrationPageRouteId = null; } } int?parentPageId = page.ParentPageId; pageService.Delete(page); if (cbDeleteInteractions.Checked) { var interactionComponentService = new InteractionComponentService(rockContext); var componentQuery = interactionComponentService.QueryByPage(page); interactionComponentService.DeleteRange(componentQuery); } rockContext.SaveChanges(); // reload page, selecting the deleted page's parent var qryParams = new Dictionary <string, string>(); if (parentPageId.HasValue) { qryParams["Page"] = parentPageId.ToString(); string expandedIds = this.Request.Params["ExpandedIds"]; if (expandedIds != null) { // remove the current pageId param to avoid extra treeview flash var expandedIdList = expandedIds.SplitDelimitedValues().AsIntegerList(); expandedIdList.Remove(parentPageId.Value); qryParams["ExpandedIds"] = expandedIdList.AsDelimited(","); } } NavigateToPage(RockPage.Guid, qryParams); } }