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


C# DefinedValueService.Delete方法代码示例

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


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

示例1: gDefinedValues_Delete

        /// <summary>
        /// Handles the Delete event of the gDefinedValues 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 gDefinedValues_Delete( object sender, RowEventArgs e )
        {
            var valueService = new DefinedValueService();

            DefinedValue value = valueService.Get( (int)e.RowKeyValue );

            DefinedTypeCache.Flush(value.DefinedTypeId);
            DefinedValueCache.Flush(value.Id);

            if ( value != null )
            {
                valueService.Delete( value, CurrentPersonId );
                valueService.Save( value, CurrentPersonId );
            }

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

示例2: gDefinedValues_Delete

        /// <summary>
        /// Handles the Delete event of the gDefinedValues 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 gDefinedValues_Delete( object sender, RowEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                var definedValueService = new DefinedValueService( rockContext );
                var value = definedValueService.Get( e.RowKeyId );
                if ( value != null )
                {
                    string errorMessage;
                    if ( !definedValueService.CanDelete( value, out errorMessage ) )
                    {
                        mdGridWarningValues.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    definedValueService.Delete( value );
                    rockContext.SaveChanges();

                    DefinedTypeCache.Flush( value.DefinedTypeId );
                    DefinedValueCache.Flush( value.Id );
                }

                BindPackageGrid();
            }
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:30,代码来源:ProtectMyMinistrySettings.ascx.cs

示例3: gDefinedType_Delete

        /// <summary>
        /// Handles the Delete event of the gDefinedType 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 gDefinedType_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var definedValueService = new DefinedValueService( rockContext );
            var definedTypeService = new DefinedTypeService( rockContext );

            DefinedType type = definedTypeService.Get( e.RowKeyId );

            if ( type != null )
            {
                string errorMessage;
                if ( !definedTypeService.CanDelete( type, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                // if this DefinedType has DefinedValues, see if they can be deleted
                var definedValues = definedValueService.GetByDefinedTypeId( type.Id ).ToList();

                foreach ( var value in definedValues )
                {
                    if ( !definedValueService.CanDelete( value, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }
                }

                foreach ( var value in definedValues )
                {
                    definedValueService.Delete( value );
                }

                definedTypeService.Delete( type );

                rockContext.SaveChanges();
            }

            gDefinedType_Bind();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:46,代码来源:DefinedTypeList.ascx.cs

示例4: gDefinedType_Delete

        /// <summary>
        /// Handles the Delete event of the gDefinedType 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 gDefinedType_Delete( object sender, RowEventArgs e )
        {
            var definedValueService = new DefinedValueService();
            var definedTypeService = new DefinedTypeService();

            DefinedType type = definedTypeService.Get( e.RowKeyId );

            if ( type != null )
            {
                string errorMessage;
                if ( !definedTypeService.CanDelete( type, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                // if this DefinedType has DefinedValues, see if they can be deleted
                var definedValues = definedValueService.GetByDefinedTypeId( type.Id ).ToList();

                foreach ( var value in definedValues )
                {
                    if ( !definedValueService.CanDelete( value, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }
                }

                RockTransactionScope.WrapTransaction( () =>
                {
                    foreach ( var value in definedValues )
                    {
                        definedValueService.Delete( value, CurrentPersonId );
                        definedValueService.Save( value, CurrentPersonId );
                    }

                    definedTypeService.Delete( type, CurrentPersonId );
                    definedTypeService.Save( type, CurrentPersonId );
                } );
            }

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

示例5: rGridValue_Delete

        /// <summary>
        /// Handles the Delete event of the rGridValue 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 rGridValue_Delete( object sender, RowEventArgs e )
        {
            var valueService = new DefinedValueService();

            DefinedValue value = valueService.Get( (int)rGridValue.DataKeys[e.RowIndex]["id"] );

            if ( value != null )
            {
                valueService.Delete( value, CurrentPersonId );
                valueService.Save( value, CurrentPersonId );
            }

            rGridValue_Bind( hfIdType.Value );
        }
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:19,代码来源:DefinedTypes.ascx.cs

示例6: rGridType_Delete

        /// <summary>
        /// Handles the Delete event of the rGridType 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 rGridType_Delete( object sender, RowEventArgs e )
        {
            DefinedType type = new DefinedTypeService().Get( (int)rGridType.DataKeys[e.RowIndex]["id"] );

            var valueService = new DefinedValueService();
            var typeService = new DefinedTypeService();

            if ( type != null )
            {
                // if this DefinedType has DefinedValues, delete them
                var hasDefinedValues = valueService
                .GetByDefinedTypeId( type.Id )
                .ToList();

                foreach ( var value in hasDefinedValues )
                {
                    valueService.Delete( value, CurrentPersonId );
                    valueService.Save( value, CurrentPersonId );
                }

                typeService.Delete( type, CurrentPersonId );
                typeService.Save( type, CurrentPersonId );
            }

            rGridType_Bind();
        }
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:31,代码来源:DefinedTypes.ascx.cs


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