public IEnumerable <ISellableInventoryItemEntryMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <ISellableInventoryItemEntryMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _sellableInventoryItemEntryMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (SellableInventoryItemEntryMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? SellableInventoryItemEntryMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , SellableInventoryItemEntryMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _sellableInventoryItemEntryMvoApplicationService.Get(SellableInventoryItemEntryMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , SellableInventoryItemEntryMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <ISellableInventoryItemEntryMvoStateDto>(); foreach (var s in states) { var dto = s is SellableInventoryItemEntryMvoStateDtoWrapper ? (SellableInventoryItemEntryMvoStateDtoWrapper)s : new SellableInventoryItemEntryMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchSellableInventoryItemEntryMvoDto value) { try { SellableInventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _sellableInventoryItemEntryMvoApplicationService.When(value as IMergePatchSellableInventoryItemEntryMvo); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public SellableInventoryItemEntryMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = SellableInventoryItemEntryMvosControllerUtils.ParseIdString(id); var conv = new SellableInventoryItemEntryMvoStateEventDtoConverter(); var se = _sellableInventoryItemEntryMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToSellableInventoryItemEntryMvoStateEventDto(se)); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateSellableInventoryItemEntryMvoDto value) { try { if (value.SellableInventoryItemEntryId == default(SellableInventoryItemEntryId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "SellableInventoryItemEntryMvo"); } _sellableInventoryItemEntryMvoApplicationService.When(value as ICreateSellableInventoryItemEntryMvo); var idObj = value.SellableInventoryItemEntryId; return(Request.CreateResponse <SellableInventoryItemEntryId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _sellableInventoryItemEntryMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (SellableInventoryItemEntryMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? SellableInventoryItemEntryMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _sellableInventoryItemEntryMvoApplicationService.GetCount(SellableInventoryItemEntryMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in SellableInventoryItemEntryMvoMetadata.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 = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteSellableInventoryItemEntryMvoDto value) { try { // /////////////////////////////// if (value.SellableInventoryItemVersion != default(long)) { value.CommandType = CommandType.MergePatch; SellableInventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _sellableInventoryItemEntryMvoApplicationService.When(value as IMergePatchSellableInventoryItemEntryMvo); return; } // /////////////////////////////// SellableInventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _sellableInventoryItemEntryMvoApplicationService.When(value as ICreateSellableInventoryItemEntryMvo); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public ISellableInventoryItemEntryMvoStateDto Get(string id, string fields = null) { try { var idObj = SellableInventoryItemEntryMvosControllerUtils.ParseIdString(id); var state = _sellableInventoryItemEntryMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new SellableInventoryItemEntryMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }