public IEnumerable <IInventoryItemStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IInventoryItemState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _inventoryItemApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InventoryItemMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryItemMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , InventoryItemsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _inventoryItemApplicationService.Get(InventoryItemsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , InventoryItemsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IInventoryItemStateDto>(); foreach (var s in states) { var dto = s is InventoryItemStateDtoWrapper ? (InventoryItemStateDtoWrapper)s : new InventoryItemStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public InventoryItemStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = InventoryItemsControllerUtils.ParseIdString(id); var conv = new InventoryItemStateEventDtoConverter(); var se = _inventoryItemApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToInventoryItemStateEventDto(se)); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IInventoryItemEntryStateDto GetInventoryItemEntry(string inventoryItemId, long entrySeqId) { try { var state = (InventoryItemEntryState)_inventoryItemApplicationService.GetInventoryItemEntry(((new ValueObjectTextFormatter <InventoryItemId>()).Parse(inventoryItemId)), entrySeqId); if (state == null) { return(null); } var stateDto = new InventoryItemEntryStateDtoWrapper(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _inventoryItemApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InventoryItemMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryItemMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _inventoryItemApplicationService.GetCount(InventoryItemsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in InventoryItemMetadata.Instance.Properties) { if (p.IsFilteringProperty) { var pdto = new PropertyMetadataDto(p.Name, p.TypeName, p.IsFilteringProperty, !String.IsNullOrWhiteSpace(p.SourceChainingName) ? p.SourceChainingName : (!String.IsNullOrWhiteSpace(p.DerivedFrom) ? p.DerivedFrom : p.Name)); filtering.Add(pdto); } } return(filtering); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IInventoryItemEntryStateDto> GetInventoryItemEntries(string inventoryItemId) { try { var states = _inventoryItemApplicationService.GetInventoryItemEntries(((new ValueObjectTextFormatter <InventoryItemId>()).Parse(inventoryItemId))); if (states == null) { return(null); } var stateDtos = new List <IInventoryItemEntryStateDto>(); foreach (var s in states) { var dto = s is InventoryItemEntryStateDtoWrapper ? (InventoryItemEntryStateDtoWrapper)s : new InventoryItemEntryStateDtoWrapper((IInventoryItemEntryState)s); dto.AllFieldsReturned = true; stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IInventoryItemStateDto Get(string id, string fields = null) { try { var idObj = InventoryItemsControllerUtils.ParseIdString(id); var state = _inventoryItemApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new InventoryItemStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = InventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }