public IEnumerable <IInOutStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IInOutState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _inOutApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InOutMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InOutMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , InOutsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _inOutApplicationService.Get(InOutsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , InOutsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IInOutStateDto>(); foreach (var s in states) { var dto = s is InOutStateDtoWrapper ? (InOutStateDtoWrapper)s : new InOutStateDtoWrapper(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 = _inOutApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InOutMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InOutMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _inOutApplicationService.GetCount(InOutsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }