Exemplo n.º 1
0
        public static List<SubEntityRecord> GetDropdownValues(ProviderAdminDetailView parent, int providerId)
        {
            IEnumerable<ProviderProviderTypeDto> existingTypes = new List<ProviderProviderTypeDto>();
            if (providerId != 0)
                existingTypes = GetProviderProviderTypes(parent, providerId);

            var request = new ListProviderTypeRequest() { IsEnabled = true };
            var types = parent.ProcessRequest<ListProviderTypeResponse>(request).ProviderTypes;
            var records = new List<SubEntityRecord>();

            foreach (var type in types.Where(t => !existingTypes.Any(e => e.ProviderTypeId == t.Id)))
            {
                var record = new SubEntityRecord();
                record.DisplayName = type.Name;
                record.Id = type.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(_providerTypeId, _providerTypeId, FieldTypes.Hidden, type.Id));
                record.Fields.Add(new Field(_providerTypeName, "Type Name", FieldTypes.Label, type.Name));

                records.Add(record);
            }

            return records;
        }
Exemplo n.º 2
0
 private void GetProviderTypes(List<KeyValuePair<object, object>> records)
 {
     var request = new ListProviderTypeRequest() { IsEnabled = true };
     var items = _view.ProcessRequest<ListProviderTypeResponse>(request).ProviderTypes;
     foreach (var item in items)
         records.Add(new KeyValuePair<object, object>(item.Name, item.Id));
 }
        /// <summary>
        /// Queries the DB using the existing ListProvidersHandler
        /// </summary>
        private ListProviderTypeResponse QueryData()
        {
            var listRequest = new ListProviderTypeRequest();

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