Пример #1
0
 public IEnumerable <IUomConversionStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IUomConversionState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _uomConversionApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                   , n => (UomConversionMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? UomConversionMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                           , UomConversionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _uomConversionApplicationService.Get(UomConversionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                           , UomConversionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IUomConversionStateDto>();
         foreach (var s in states)
         {
             var dto = s is UomConversionStateDtoWrapper ? (UomConversionStateDtoWrapper)s : new UomConversionStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #2
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _uomConversionApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                       , n => (UomConversionMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? UomConversionMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _uomConversionApplicationService.GetCount(UomConversionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }