/// <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(); } }
/// <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; } } } }