示例#1
0
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            int definedTypeId = hfDefinedTypeId.ValueAsInt();
            DefinedTypeCache.Flush( definedTypeId );

            using ( new UnitOfWorkScope() )
            {
                var definedValueService = new DefinedValueService();               
                var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order );
                definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex, CurrentPersonId );
                BindDefinedValuesGrid();
            }
        }
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            int definedTypeId = hfDefinedTypeId.ValueAsInt();
            DefinedTypeCache.Flush( definedTypeId );

            var rockContext = new RockContext();
            var definedValueService = new DefinedValueService( rockContext );
            var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order ).ThenBy( a => a.Name);
            var changedIds = definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();

            Rock.Web.Cache.DefinedTypeCache.Flush( definedTypeId );
            foreach(int id in changedIds)
            {
                Rock.Web.Cache.DefinedValueCache.Flush( id );
            }

            BindDefinedValuesGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            var definedType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() );
            if ( definedType != null )
            {
                var changedIds = new List<int>();

                using ( var rockContext = new RockContext() )
                {
                    var definedValueService = new DefinedValueService( rockContext );
                    var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedType.Id ).OrderBy( a => a.Order ).ThenBy( a => a.Value );
                    changedIds = definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
                    rockContext.SaveChanges();
                }

                DefinedTypeCache.Flush( definedType.Id );
                foreach ( int id in changedIds )
                {
                    Rock.Web.Cache.DefinedValueCache.Flush( id );
                }
            }

            BindPackageGrid();
        }
示例#4
0
        /// <summary>
        /// Handles the GridReorder event of the gLinks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        void gLinks_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                var service = new DefinedValueService( rockContext );
                var definedValues = service.Queryable().Where( a => a.DefinedTypeId == _definedType.Id ).OrderBy( a => a.Order ).ThenBy( a => a.Value );
                var changedIds = service.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();

                foreach ( int id in changedIds )
                {
                    Rock.Web.Cache.DefinedValueCache.Flush( id );
                }
            }

            DefinedTypeCache.Flush( _definedType.Id );

            BindGrid();
        }