/// <summary>
/// Finds the first group.
/// </summary>
/// <returns></returns>
private Group FindFirstGroup()
{
var groupService = new GroupService( new RockContext() );
var includedGroupTypeIds = hfGroupTypesInclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList();
var excludedGroupTypeIds = hfGroupTypesExclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList();
// if specific group types are specified, show the groups regardless of ShowInNavigation
bool limitToShowInNavigation = !includedGroupTypeIds.Any();
var qry = groupService.GetChildren( 0, hfRootGroupId.ValueAsInt(), hfLimitToSecurityRoleGroups.Value.AsBoolean(), includedGroupTypeIds, excludedGroupTypeIds, !tglHideInactiveGroups.Checked, limitToShowInNavigation );
foreach ( var group in qry.OrderBy( g => g.Name ) )
{
// return first group they are authorized to view
if ( group.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
return group;
}
}
return null;
}