/// <summary> /// Shows the selected pane. /// </summary> private void ShowSelectedPane() { if (LocationTypeTab.Equals(MEMBER_LOCATION_TAB_TITLE)) { pnlMemberSelect.Visible = true; pnlLocationSelect.Visible = false; } else if (LocationTypeTab.Equals(OTHER_LOCATION_TAB_TITLE)) { pnlMemberSelect.Visible = false; pnlLocationSelect.Visible = true; } }
/// <summary> /// Handles the SaveClick event of the dlgLocations control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void dlgLocations_SaveClick(object sender, EventArgs e) { Location location = null; int? memberPersonAliasId = null; RockContext rockContext = new RockContext(); if (LocationTypeTab.Equals(MEMBER_LOCATION_TAB_TITLE)) { if (ddlMember.SelectedValue != null) { var ids = ddlMember.SelectedValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).AsIntegerList().ToArray(); if (ids.Length == 2) { int locationId = ids[0]; int primaryAliasId = ids[1]; var dbLocation = new LocationService(rockContext).Get(locationId); if (dbLocation != null) { location = new Location(); location.CopyPropertiesFrom(dbLocation); } memberPersonAliasId = new PersonAliasService(rockContext).GetPrimaryAliasId(primaryAliasId); } } } else { if (locpGroupLocation.Location != null) { location = new Location(); location.CopyPropertiesFrom(locpGroupLocation.Location); } } if (location != null) { GroupLocation groupLocation = null; Guid guid = hfAddLocationGroupGuid.Value.AsGuid(); if (!guid.IsEmpty()) { groupLocation = GroupLocationsState.FirstOrDefault(l => l.Guid.Equals(guid)); } if (groupLocation == null) { groupLocation = new GroupLocation(); GroupLocationsState.Add(groupLocation); } groupLocation.GroupMemberPersonAliasId = memberPersonAliasId; groupLocation.Location = location; groupLocation.LocationId = groupLocation.Location.Id; groupLocation.GroupLocationTypeValueId = ddlLocationType.SelectedValueAsId(); var selectedIds = spSchedules.SelectedValuesAsInt(); groupLocation.Schedules = new ScheduleService(rockContext).Queryable() .Where(s => selectedIds.Contains(s.Id)).ToList(); if (groupLocation.GroupLocationTypeValueId.HasValue) { groupLocation.GroupLocationTypeValue = new DefinedValue(); var definedValue = new DefinedValueService(rockContext).Get(groupLocation.GroupLocationTypeValueId.Value); if (definedValue != null) { groupLocation.GroupLocationTypeValue.CopyPropertiesFrom(definedValue); } } } BindLocationsGrid(); dlgLocations.Hide(); hfActiveDialog.Value = string.Empty; }