/// <summary> /// Handles the SaveClick event of the dlgConnectorGroupDetails 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 dlgConnectorGroupDetails_SaveClick( object sender, EventArgs e ) { Guid guid = hfConnectorGroupGuid.Value.AsGuid(); var connectorGroup = ConnectorGroupsState.Where( g => g.Guid.Equals( guid ) ).FirstOrDefault(); if ( connectorGroup == null ) { connectorGroup = new GroupStateObj(); connectorGroup.Guid = Guid.NewGuid(); ConnectorGroupsState.Add( connectorGroup ); } connectorGroup.CampusId = cpCampus.SelectedCampusId; if ( connectorGroup.CampusId.HasValue ) { var campus = CampusCache.Read( connectorGroup.CampusId.Value ); if ( campus != null ) { connectorGroup.CampusName = campus.Name; } else { connectorGroup.CampusName = "All"; connectorGroup.CampusId = null; } } else { connectorGroup.CampusName = "All"; } connectorGroup.GroupId = gpGroup.ItemId.AsInteger(); var group = new GroupService( new RockContext() ).Queryable().Where( g => g.Id.ToString() == gpGroup.ItemId ).FirstOrDefault(); if ( group != null ) { connectorGroup.GroupName = group.Name; connectorGroup.GroupTypeId = group.GroupTypeId; } BindConnectorGroupsGrid(); HideDialog(); }
/// <summary> /// Handles the SaveClick event of the dlgGroupDetails 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 dlgGroupDetails_SaveClick( object sender, EventArgs e ) { int? groupId = gpOpportunityGroup.SelectedValueAsInt(); if ( groupId.HasValue ) { var rockContext = new RockContext(); var group = new GroupService( rockContext ).Get( groupId.Value ); if ( group != null ) { int? groupTypeId = ddlGroupType.SelectedValueAsInt(); if( groupTypeId.HasValue && group.GroupTypeId != groupTypeId.Value ) { string groupTypeName = ddlGroupType.SelectedItem.Text; nbInvalidGroupType.Text = string.Format( "<p>The selected group is not a <strong>{0}</strong> type. Please select a group that has a group type of <strong>{0}</strong>.", groupTypeName ); nbInvalidGroupType.Visible = true; return; } var groupStateObj = GroupsState.Where( g => g.GroupId == group.Id ).FirstOrDefault(); if ( groupStateObj == null ) { groupStateObj = new GroupStateObj(); groupStateObj.GroupId = group.Id; groupStateObj.GroupName = group.Name; groupStateObj.GroupTypeId = group.GroupTypeId; groupStateObj.CampusId = group.CampusId; groupStateObj.CampusName = group.Campus != null ? group.Campus.Name : string.Empty; GroupsState.Add( groupStateObj ); } BindGroupGrid(); HideDialog(); } } }
/// <summary> /// Handles the SaveClick event of the dlgGroupDetails 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 dlgGroupDetails_SaveClick( object sender, EventArgs e ) { int? groupId = gpOpportunityGroup.SelectedValueAsInt(); if ( groupId.HasValue ) { var rockContext = new RockContext(); var group = new GroupService( rockContext ).Get( groupId.Value ); if ( group != null ) { if ( !ValidPlacementGroups() ) { return; } var groupStateObj = GroupsState.Where( g => g.GroupId == group.Id ).FirstOrDefault(); if ( groupStateObj == null ) { groupStateObj = new GroupStateObj(); groupStateObj.GroupId = group.Id; groupStateObj.GroupName = group.Name; groupStateObj.GroupTypeName = group.GroupType != null ? group.GroupType.Name : string.Empty; groupStateObj.GroupTypeId = group.GroupTypeId; groupStateObj.CampusId = group.CampusId; groupStateObj.CampusName = group.Campus != null ? group.Campus.Name : string.Empty; GroupsState.Add( groupStateObj ); } BindGroupGrid(); HideDialog(); } } }