当前位置: 首页>>代码示例>>C#>>正文


C# GroupTypeService.CanDelete方法代码示例

本文整理汇总了C#中Rock.Model.GroupTypeService.CanDelete方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService.CanDelete方法的具体用法?C# GroupTypeService.CanDelete怎么用?C# GroupTypeService.CanDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.GroupTypeService的用法示例。


在下文中一共展示了GroupTypeService.CanDelete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: gGroupType_Delete

        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            GroupTypeService groupTypeService = new GroupTypeService( rockContext );
            GroupType groupType = groupTypeService.Get( e.RowKeyId );

            if ( groupType != null )
            {
                int groupTypeId = groupType.Id;

                if ( !groupType.IsAuthorized( "Administrate", CurrentPerson ) )
                {
                    mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
                    return;
                }

                string errorMessage;
                if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
                    return;
                }

                groupType.ParentGroupTypes.Clear();
                groupType.ChildGroupTypes.Clear();

                groupTypeService.Delete( groupType );
                rockContext.SaveChanges();

                GroupTypeCache.Flush( groupTypeId );
            }

            BindGrid();
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:39,代码来源:GroupTypeList.ascx.cs

示例2: btnDelete_Click

        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click( object sender, EventArgs e )
        {
            var rockContext = new RockContext();
            GroupTypeService groupTypeService = new GroupTypeService( rockContext );
            GroupType groupType = groupTypeService.Get( hfGroupTypeId.Value.AsInteger() );

            if ( groupType != null )
            {
                string errorMessage;
                if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
                {
                    mdDeleteWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                int groupTypeId = groupType.Id;

                groupType.ParentGroupTypes.Clear();
                groupType.ChildGroupTypes.Clear();

                groupTypeService.Delete( groupType );
                rockContext.SaveChanges();

                GroupTypeCache.Flush( groupTypeId );
                Rock.CheckIn.KioskDevice.FlushAll();
            }

            var pageRef = new PageReference( CurrentPageReference.PageId, CurrentPageReference.RouteId );
            NavigateToPage( pageRef );
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:35,代码来源:CheckinTypeDetail.ascx.cs

示例3: CheckinAreaRow_DeleteAreaClick

        private void CheckinAreaRow_DeleteAreaClick( object sender, EventArgs e )
        {
            var row = sender as CheckinAreaRow;

            using ( var rockContext = new RockContext() )
            {
                var groupTypeService = new GroupTypeService( rockContext );
                var groupType = groupTypeService.Get( row.GroupTypeGuid );
                if ( groupType != null )
                {
                    // Warn if this GroupType or any of its child grouptypes (recursive) is being used as an Inherited Group Type. Probably shouldn't happen, but just in case
                    if ( IsInheritedGroupTypeRecursive( groupType, groupTypeService ) )
                    {
                        nbDeleteWarning.Text = "WARNING - Cannot delete. This group type or one of its child group types is assigned as an inherited group type.";
                        nbDeleteWarning.Visible = true;
                        return;
                    }

                    string errorMessage;
                    if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
                    {
                        nbDeleteWarning.Text = "WARNING - Cannot Delete: " + errorMessage;
                        nbDeleteWarning.Visible = true;
                        return;
                    }

                    int id = groupType.Id;

                    groupType.ParentGroupTypes.Clear();
                    groupType.ChildGroupTypes.Clear();

                    groupTypeService.Delete( groupType );
                    rockContext.SaveChanges();

                    GroupTypeCache.Flush( id );
                    Rock.CheckIn.KioskDevice.FlushAll();

                    SelectArea( null );
                }
            }

            BuildRows();
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:43,代码来源:CheckinAreas.ascx.cs

示例4: gGroupType_Delete

        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete( object sender, RowEventArgs e )
        {
            RockTransactionScope.WrapTransaction( () =>
            {
                GroupTypeService groupTypeService = new GroupTypeService();
                GroupType groupType = groupTypeService.Get( e.RowKeyId );

                if ( groupType != null )
                {
                    int groupTypeId = groupType.Id;

                    if ( !groupType.IsAuthorized("Administrate", CurrentPerson))
                    {
                        mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
                        return;
                    }

                    string errorMessage;
                    if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
                        return;
                    }

                    groupTypeService.Delete( groupType, CurrentPersonId );
                    groupTypeService.Save( groupType, CurrentPersonId );

                    GroupTypeCache.Flush( groupTypeId );
                }
            } );

            BindGrid();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:38,代码来源:GroupTypeList.ascx.cs


注:本文中的Rock.Model.GroupTypeService.CanDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。