/// <summary>
/// Loads the dropdowns.
/// </summary>
private void BindLocations()
{
var locations = new Dictionary<int, string> { { 0, "" } };
if ( _group != null )
{
var locationPaths = new Dictionary<int, string>();
var locationService = new LocationService( _rockContext );
foreach ( var location in _group.GroupLocations
.Where( l =>
l.Location.Name != null &&
l.Location.Name != "" )
.Select( l => l.Location ) )
{
// Get location path
string parentLocationPath = string.Empty;
if ( location.ParentLocationId.HasValue )
{
var locId = location.ParentLocationId.Value;
if ( !locationPaths.ContainsKey( locId ) )
{
locationPaths.Add( locId, locationService.GetPath( locId ) );
}
parentLocationPath = locationPaths[locId];
}
if ( !locations.ContainsKey( location.Id ) )
{
locations.Add( location.Id, new List<string> { parentLocationPath, location.Name }.AsDelimited( " > " ) );
}
}
}
if ( locations.Any() )
{
ddlLocation.DataSource = locations;
ddlLocation.DataBind();
}
}