Exemple #1
0
        /// <summary>
        /// Updates the selection from page parameters.
        /// </summary>
        /// <param name="selection">The selection.</param>
        /// <param name="rockBlock">The rock block.</param>
        /// <returns></returns>
        public string UpdateSelectionFromPageParameters( string selection, Rock.Web.UI.RockBlock rockBlock )
        {
            if ( !string.IsNullOrWhiteSpace( selection ) )
            {
                string[] selectionValues = selection.Split( '|' );
                if ( selectionValues.Length >= 1 )
                {
                    var campusId = rockBlock.PageParameter( "CampusId" ).AsIntegerOrNull();
                    if ( campusId == null )
                    {
                        var campusEntity = rockBlock.ContextEntity<Campus>();
                        if ( campusEntity != null )
                        {
                            campusId = campusEntity.Id;
                        }
                    }

                    if ( campusId.HasValue )
                    {
                        var selectedCampus = CampusCache.Read( campusId.Value );
                        if ( selectedCampus != null )
                        {
                            selectionValues[0] = selectedCampus.Guid.ToString();
                            return selectionValues.ToList().AsDelimited( "|" );
                        }
                    }
                }
            }

            return selection;
        }