public void Patch(string id, [FromBody] MergePatchInventoryPostingRuleDto value) { try { InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as IMergePatchInventoryPostingRule); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IInventoryPostingRuleStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IInventoryPostingRuleState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _inventoryPostingRuleApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InventoryPostingRuleMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryPostingRuleMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , InventoryPostingRulesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _inventoryPostingRuleApplicationService.Get(InventoryPostingRulesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , InventoryPostingRulesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IInventoryPostingRuleStateDto>(); foreach (var s in states) { var dto = s is InventoryPostingRuleStateDtoWrapper ? (InventoryPostingRuleStateDtoWrapper)s : new InventoryPostingRuleStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public InventoryPostingRuleStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new InventoryPostingRuleStateEventDtoConverter(); var se = _inventoryPostingRuleApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToInventoryPostingRuleStateEventDto(se)); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteInventoryPostingRuleDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as IDeleteInventoryPostingRule); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateInventoryPostingRuleDto value) { try { if (value.InventoryPostingRuleId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "InventoryPostingRule"); } _inventoryPostingRuleApplicationService.When(value as ICreateInventoryPostingRule); var idObj = value.InventoryPostingRuleId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _inventoryPostingRuleApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (InventoryPostingRuleMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryPostingRuleMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _inventoryPostingRuleApplicationService.GetCount(InventoryPostingRulesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in InventoryPostingRuleMetadata.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 = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteInventoryPostingRuleDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as IMergePatchInventoryPostingRule); return; } // /////////////////////////////// InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as ICreateInventoryPostingRule); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IInventoryPostingRuleStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _inventoryPostingRuleApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new InventoryPostingRuleStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(InventoryPostingRulesControllerUtils.GetFilterPropertyType(propertyName)); }