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