Пример #1
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(PartiesControllerUtils.GetFilterPropertyType(propertyName));
 }
Пример #2
0
 public IEnumerable <IOrganizationStateDto> Get(string parentId = null, string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         var parentIdObj = parentId == null ? null : parentId;
         IEnumerable <IOrganizationState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             if (parentIdObj == null)
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetRootIds(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                      , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                              , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = PartiesControllerUtils.ToOrganizationStateCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetRoots(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                   , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                           , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
             else
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetChildIds(parentIdObj, CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                                    , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                               , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = PartiesControllerUtils.ToOrganizationStateCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetChildren(parentIdObj, CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                                   , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                              , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
         }
         else
         {
             if (parentIdObj == null)
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetRootIds(OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                              , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = PartiesControllerUtils.ToOrganizationStateCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetRoots(OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                           , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
             else
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetChildIds(parentIdObj, OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                               , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = PartiesControllerUtils.ToOrganizationStateCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetChildren(parentIdObj, OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                              , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
         }
         var stateDtos = new List <IOrganizationStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrganizationStateDtoWrapper ? (OrganizationStateDtoWrapper)s : new OrganizationStateDtoWrapper((IOrganizationState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }