public static List<SubEntityRecord> GetDropdownValues(LocationAdminDetailView parent, int orgUnitId) { IEnumerable<OrgUnitServicesDto> existingServices = new List<OrgUnitServicesDto>(); if (orgUnitId != 0) existingServices = GetOrgUnitServices(parent, orgUnitId); var request = new ListServicesRequest() { IsEnabled = true }; var services = parent.ProcessRequest<ListServicesResponse>(request).Services; var records = new List<SubEntityRecord>(); foreach (var service in services.Where(i => !existingServices.Any(e => e.ServiceId == i.Id))) { var record = new SubEntityRecord(); record.DisplayName = service.Name; record.Id = service.Id; record.Fields.Add(new Field(_idField, "Id", FieldTypes.Hidden, null)); record.Fields.Add(new Field(_orgUnitIdField, _orgUnitIdField, FieldTypes.Hidden, orgUnitId)); record.Fields.Add(new Field(_serviceIdField, _serviceIdField, FieldTypes.Hidden, service.Id)); record.Fields.Add(new Field(_nameField, "Name", FieldTypes.Label, service.Name)); records.Add(record); } return records; }
private ListServicesResponse QueryData() { var listRequest = new ListServicesRequest(); //Paging listRequest.PageSize = _viewModel.PageSize; listRequest.RequestedPage = _viewModel.PageNumber; ///Sorting if (!string.IsNullOrEmpty(_viewModel.SortColumn)) listRequest.SortExpression = _viewModel.SortColumn + " " + _viewModel.SortDirection; //Filters var keywordFilterValue = string.IsNullOrEmpty(_viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue) ? string.Empty : _viewModel.FilterFields.Single(f => f.FieldName == "Keyword").FieldValue; if (!string.IsNullOrEmpty(keywordFilterValue)) listRequest.NameFilter = keywordFilterValue; 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<ListServicesResponse>(listRequest); }