public static List<KeyValuePair<object, object>> GetLocationContextOptions(DataProxyBase dataProxy)
        {
            var request = new ListOrgUnitAssociationsRequest() { SecondaryIsSite = true, IsEnabled = true, PageSize = -1, SortField = "SecondaryPath", SortDirection = "Ascending" };
            var response = dataProxy.ProcessRequest<ListOrgUnitAssociationsResponse>(request);

            var locations = new List<KeyValuePair<object, object>>();

            locations.Add(new KeyValuePair<object, object>(0, "- Automatic -"));

            foreach (var association in response.OrgUnitAssociations)
            {
                locations.Add(new KeyValuePair<object, object>(association.SecondaryId.Value, association.SecondaryPath));
            }

            return locations;
        }
        public IEnumerable<SettingLocation> BuildSettingLocations(AdminSettingsViewModel viewModel, int? locationId, string groupName)
        {
            var request = new ListOrgUnitAssociationsRequest() { SecondaryIsSite = true, IsEnabled = true, PageSize = -1, SortField = "SecondaryPath", SortDirection = "Ascending" };
            var response = ProcessRequest<ListOrgUnitAssociationsResponse>(request);

            var locations = new List<SettingLocation>();

            locations.Add(new SettingLocation() { Id = 0, Name = "- Global Defaults -" });

            foreach (var association in response.OrgUnitAssociations)
            {
                locations.Add(new SettingLocation() { Id = association.SecondaryId.Value, Name = association.SecondaryPath });
            }

            if (locationId.HasValue)
            {
                viewModel.SelectedLocation = locations.SingleOrDefault(l => l.Id == locationId);
                viewModel.SelectedLocation.HasUniqueSettings = HasUniqueSettings(locationId, groupName);
            }
            else
                viewModel.SelectedLocation = locations[0];

            return locations;
        }
        /// <summary>
        /// Queries the DB using the existing Handler
        /// </summary>
        private ListOrgUnitAssociationsResponse QueryData(ConvertServiceRequest request)
        {
            var listRequest = new ListOrgUnitAssociationsRequest();

            if (request.Parameters.ContainsKey("Depth") && !string.IsNullOrEmpty(request.Parameters["Depth"]))
                listRequest.Depth = Convert.ToInt32(request.Parameters["Depth"]);

            // Lazy-Loading
            if (request.Parameters.ContainsKey("StartNodeId") && !string.IsNullOrEmpty(request.Parameters["StartNodeId"]))
                listRequest.PrimaryId = Convert.ToInt32(request.Parameters["StartNodeId"]);

            //Paging
            listRequest.PageSize = _viewModel.PageSize;
            listRequest.RequestedPage = _viewModel.PageNumber;

            //Sorting
            if (!string.IsNullOrEmpty(_viewModel.SortColumn))
            {
                listRequest.SortField = _viewModel.SortColumn;
                listRequest.SortDirection = _viewModel.SortDirection.ToLowerInvariant() == "asc" ? "Ascending" : "Descending";
            }

            //Filter
            var nameValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Name").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Name").FieldValue;
            if (!string.IsNullOrEmpty(nameValue))
                listRequest.SecondaryName = nameValue;

            var keywordsValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue;
            if (!string.IsNullOrEmpty(keywordsValue))
                listRequest.SecondaryKeywords = keywordsValue;

            var enabledFilterValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Enabled").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Enabled").FieldValue;
            if (!string.IsNullOrEmpty(enabledFilterValue) && enabledFilterValue != "All")
                listRequest.IsEnabled = enabledFilterValue == "Enabled";

            return ProcessRequest<ListOrgUnitAssociationsResponse>(listRequest);
        }