/// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger( upnlContent );

            var entitySetId = PageParameter( "WaitListSetId" ).AsIntegerOrNull();
            if ( entitySetId.HasValue )
            {
                // get the registrant Ids
                var registrantIds = new EntitySetItemService( _rockContext )
                    .Queryable().AsNoTracking()
                    .Where( i => i.EntitySetId == entitySetId )
                    .Select( i => i.EntityId )
                    .ToList();

                // get the registrants
                _registrants = new RegistrationRegistrantService( _rockContext )
                    .Queryable()
                    .Where( r => registrantIds.Contains( r.Id ) )
                    .ToList();

                // get the first registration
                _firstRegistration = _registrants
                    .Where( r => r.Registration != null )
                    .Select( r => r.Registration )
                    .FirstOrDefault();

                // get the template
                _template = _registrants
                    .Where( r =>
                        r.Registration != null &&
                        r.Registration.RegistrationInstance != null &&
                        r.Registration.RegistrationInstance.RegistrationTemplate != null )
                    .Select( r => r.Registration.RegistrationInstance.RegistrationTemplate )
                    .FirstOrDefault();

                // Bind the grid
                rptRecipients.DataSource = _registrants
                    .GroupBy( r => r.Registration )
                    .Select( r => new RegistrationSummary {
                        Registration = r.Key,
                        Registrants = r.Key.Registrants.Where( g => registrantIds.Contains( g.Id ) ).ToList() } );
                rptRecipients.DataBind();
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads the edit details.
        /// </summary>
        private void LoadEditDetails()
        {
            if ( !Page.IsPostBack )
            {
                int? setId = PageParameter( "Set" ).AsIntegerOrNull();
                if ( setId.HasValue )
                {
                    var selectedPersonIds = new EntitySetItemService( new RockContext() )
                        .GetByEntitySetId( setId.Value )
                        .Select( i => i.EntityId )
                        .Distinct()
                        .ToList();

                    if ( selectedPersonIds.Count == 0 )
                    {
                        ScriptManager.RegisterStartupScript( this, this.GetType(), "goBack", "history.go(-1);", true );
                    }

                    // Get the people selected
                    var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users", true )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData( people, headingKeys, CurrentPerson );
                    MergeData.EntitySetId = setId.Value;
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsIntegerOrNull();

                // Save the primary header radio button's selection
                foreach ( var col in gValues.Columns.OfType<PersonMergeField>() )
                {
                    col.OnDelete += personCol_OnDelete;
                    if ( primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex )
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            var rockContext = new RockContext();

            if ( !Page.IsPostBack )
            {
                cpCampus.Campuses = CampusCache.All();

                Individuals = new List<Individual>();
                SelectedFields = new List<string>();

                int? setId = PageParameter( "Set" ).AsIntegerOrNull();
                if ( setId.HasValue )
                {
                    var selectedPersonIds = new EntitySetItemService( rockContext )
                        .GetByEntitySetId( setId.Value )
                        .Select( i => i.EntityId )
                        .Distinct()
                        .ToList();

                    // Get the people selected
                    foreach ( var person in new PersonService( rockContext ).Queryable( true )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .Select( p => new
                        {
                            p.Id,
                            FullName = p.NickName + " " + p.LastName
                        } ) )
                    {
                        Individuals.Add( new Individual( person.Id, person.FullName ) );
                    }
                }

                SetControlSelection();
                BuildAttributes( rockContext, true );
            }
            else
            {
                SetControlSelection();
                BuildAttributes( rockContext );

                if ( ddlGroupAction.SelectedValue == "Update" )
                {
                    SetControlSelection( ddlGroupRole, "Role" );
                    SetControlSelection( ddlGroupMemberStatus, "Member Status" );
                }

                BuildGroupAttributes( rockContext );
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            nbPeople.Visible = false;

            if ( !Page.IsPostBack )
            {
                int? setId = PageParameter( "Set" ).AsIntegerOrNull();
                if (setId.HasValue)
                {
                    var selectedPersonIds = new EntitySetItemService( new RockContext() )
                        .GetByEntitySetId( setId.Value )
                        .Select( i => i.EntityId )
                        .Distinct()
                        .ToList();

                    // Get the people selected
                    var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users", true )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData( people, headingKeys );
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsIntegerOrNull();

                // Save the primary header radio button's selection
                foreach ( var col in gValues.Columns.OfType<PersonMergeField>() )
                {
                    col.OnDelete += personCol_OnDelete;
                    if (primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex)
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }