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