public static List<SubEntityRecord> GetDropdownValues(ProviderAdminDetailView parent, int providerId)
        {
            IEnumerable<ProviderLanguageDto> existingLanguages = new List<ProviderLanguageDto>();
            if (providerId != 0)
                existingLanguages = GetProviderLanguages(parent, providerId);

            var request = new ListLanguagesRequest() { IsEnabled = true };
            var languages = parent.ProcessRequest<ListLanguagesResponse>(request).Languages;
            var records = new List<SubEntityRecord>();

            foreach (var language in languages.Where(l => !existingLanguages.Any(e => e.LanguageId == l.Id)))
            {
                var record = new SubEntityRecord();
                record.DisplayName = language.Name;
                record.Id = language.Id;
                record.Fields.Add(new Field(_id, _id, FieldTypes.Hidden, null));
                record.Fields.Add(new Field(_providerId, _providerId, FieldTypes.Hidden, providerId));
                record.Fields.Add(new Field(_languageId, _languageId, FieldTypes.Hidden, language.Id));
                record.Fields.Add(new Field(_languageName, "Language Name", FieldTypes.Label, language.Name));
                record.Fields.Add(new Field(_isPrimary, "Is Primary", FieldTypes.Checkbox, false) { OnChangeCommand = "PrimaryLanguageChanged" });
                record.Fields.Add(new Field(_isFluent, "Is Fluent", FieldTypes.Checkbox, false));

                records.Add(record);
            }

            return records;
        }
 private void GetLanguages(List<KeyValuePair<object, object>> records)
 {
     var languageRequest = new ListLanguagesRequest() { IsEnabled = true };
     var languageResponse = _view.ProcessRequest<ListLanguagesResponse>(languageRequest);
     foreach (var language in languageResponse.Languages)
         records.Add(new KeyValuePair<object, object>(language.Name, language.Id));
 }
        /// <summary>
        /// Queries the DB using the existing ListProvidersHandler
        /// </summary>
        private ListLanguagesResponse QueryData()
        {
            var listRequest = new ListLanguagesRequest();

            //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";
            }

            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<ListLanguagesResponse>(listRequest);
        }