/// <summary> /// Handles the DeleteClick event of the gContentChannelItems control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param> protected void gContentChannelItems_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e) { var rockContext = new RockContext(); var contentItemService = new ContentChannelItemService(rockContext); var contentItemAssociationService = new ContentChannelItemAssociationService(rockContext); var contentItemSlugService = new ContentChannelItemSlugService(rockContext); ContentChannelItem contentItem = contentItemService.Get(e.RowKeyId); if (contentItem != null) { string errorMessage; if (!contentItemService.CanDelete(contentItem, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } rockContext.WrapTransaction(() => { contentItemAssociationService.DeleteRange(contentItem.ChildItems); contentItemAssociationService.DeleteRange(contentItem.ParentItems); contentItemService.Delete(contentItem); rockContext.SaveChanges(); }); } BindContentChannelItemsGrid(); // edit whatever the first item is, or create a new one var contentChannel = GetContentChannel(); var contentChannelItemId = new ContentChannelItemService(rockContext).Queryable().Where(a => a.ContentChannelId == contentChannel.Id).OrderBy(a => a.Order).ThenBy(a => a.Title).Select(a => ( int? )a.Id).FirstOrDefault(); EditContentChannelItem(contentChannelItemId); }
/// <summary> /// Handles the Click event of the deleteField control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> void gContentChannelItems_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); var contentItemService = new ContentChannelItemService(rockContext); var contentItemAssociationService = new ContentChannelItemAssociationService(rockContext); var contentItemSlugService = new ContentChannelItemSlugService(rockContext); var contentItem = contentItemService.Get(e.RowKeyId); if (contentItem != null) { string errorMessage; if (!contentItemService.CanDelete(contentItem, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } rockContext.WrapTransaction(() => { contentItemAssociationService.DeleteRange(contentItem.ChildItems); contentItemAssociationService.DeleteRange(contentItem.ParentItems); contentItemService.Delete(contentItem); rockContext.SaveChanges(); }); } GetData(); }
protected void lbDeleteChildItem_Click(object sender, EventArgs e) { using (var rockContext = new RockContext()) { int childItemId = hfRemoveChildItem.ValueAsInt(); var service = new ContentChannelItemService(rockContext); var childItem = service.Get(childItemId); if (childItem != null) { service.Delete(childItem); rockContext.SaveChanges(); } } BindChildItemsGrid(GetContentItem()); HideDialog(); }
/// <summary> /// Handles the Delete event of the gItems 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 gItems_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); ContentChannelItemService contentItemService = new ContentChannelItemService(rockContext); ContentChannelItem contentItem = contentItemService.Get(e.RowKeyId); if (contentItem != null) { string errorMessage; if (!contentItemService.CanDelete(contentItem, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } contentItemService.Delete(contentItem); rockContext.SaveChanges(); } BindGrids(); }
/// <summary> /// Handles the Click event of the lbDelete 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 lbDelete_Click(object sender, EventArgs e) { RockContext rockContext = new RockContext(); var contentItemService = new ContentChannelItemService(rockContext); ContentChannelItem contentItem = null; int contentItemId = hfId.Value.AsInteger(); if (contentItemId != 0) { contentItem = contentItemService .Queryable("ContentChannel,ContentChannelType") .FirstOrDefault(t => t.Id == contentItemId); } if (contentItem != null) { contentItemService.Delete(contentItem); rockContext.SaveChanges(); } ReturnToParentPage(); }
/// <summary> /// Handles the Click event of the deleteField control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> void gContentChannelItems_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var contentItemService = new ContentChannelItemService( rockContext ); var contentItem = contentItemService.Get( e.RowKeyId ); if ( contentItem != null ) { string errorMessage; if ( !contentItemService.CanDelete( contentItem, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } contentItemService.Delete( contentItem ); rockContext.SaveChanges(); } GetData(); }
/// <summary> /// Handles the Click event of the lbDelete 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 lbDelete_Click( object sender, EventArgs e ) { RockContext rockContext = new RockContext(); var contentItemService = new ContentChannelItemService( rockContext ); ContentChannelItem contentItem = null; int contentItemId = hfId.Value.AsInteger(); if ( contentItemId != 0 ) { contentItem = contentItemService .Queryable( "ContentChannel,ContentChannelType" ) .FirstOrDefault( t => t.Id == contentItemId ); } if (contentItem != null ) { contentItemService.Delete( contentItem ); rockContext.SaveChanges(); } ReturnToParentPage(); }
/// <summary> /// Handles the Delete event of the gItems 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 gItems_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var contentItemService = new ContentChannelItemService( rockContext ); var contentItemAssociationService = new ContentChannelItemAssociationService( rockContext ); ContentChannelItem contentItem = contentItemService.Get( e.RowKeyId ); if ( contentItem != null ) { string errorMessage; if ( !contentItemService.CanDelete( contentItem, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } rockContext.WrapTransaction( () => { contentItemAssociationService.DeleteRange( contentItem.ChildItems ); contentItemAssociationService.DeleteRange( contentItem.ParentItems ); contentItemService.Delete( contentItem ); rockContext.SaveChanges(); } ); } BindGrid(); }
protected void lbDeleteChildItem_Click( object sender, EventArgs e ) { using ( var rockContext = new RockContext() ) { int childItemId = hfRemoveChildItem.ValueAsInt(); var service = new ContentChannelItemService( rockContext ); var childItem = service.Get( childItemId ); if ( childItem != null ) { service.Delete( childItem ); rockContext.SaveChanges(); } } BindChildItemsGrid( GetContentItem() ); HideDialog(); }