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