public void Patch(string id, [FromBody] MergePatchShipmentItemMvoDto value) { try { ShipmentItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentItemMvoApplicationService.When(value as IMergePatchShipmentItemMvo); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IShipmentItemMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IShipmentItemMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _shipmentItemMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentItemMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentItemMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , ShipmentItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _shipmentItemMvoApplicationService.Get(ShipmentItemMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , ShipmentItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IShipmentItemMvoStateDto>(); foreach (var s in states) { var dto = s is ShipmentItemMvoStateDtoWrapper ? (ShipmentItemMvoStateDtoWrapper)s : new ShipmentItemMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public ShipmentItemMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = ShipmentItemMvosControllerUtils.ParseIdString(id); var conv = new ShipmentItemMvoStateEventDtoConverter(); var se = _shipmentItemMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToShipmentItemMvoStateEventDto(se)); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateShipmentItemMvoDto value) { try { if (value.ShipmentItemId == default(ShipmentItemId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "ShipmentItemMvo"); } _shipmentItemMvoApplicationService.When(value as ICreateShipmentItemMvo); var idObj = value.ShipmentItemId; return(Request.CreateResponse <ShipmentItemId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _shipmentItemMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentItemMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentItemMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _shipmentItemMvoApplicationService.GetCount(ShipmentItemMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in ShipmentItemMvoMetadata.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 = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentItemMvoDto value) { try { // /////////////////////////////// if (value.ShipmentVersion != default(long)) { value.CommandType = CommandType.MergePatch; ShipmentItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentItemMvoApplicationService.When(value as IMergePatchShipmentItemMvo); return; } // /////////////////////////////// ShipmentItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentItemMvoApplicationService.When(value as ICreateShipmentItemMvo); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IShipmentItemMvoStateDto Get(string id, string fields = null) { try { var idObj = ShipmentItemMvosControllerUtils.ParseIdString(id); var state = _shipmentItemMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new ShipmentItemMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = ShipmentItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(ShipmentItemMvosControllerUtils.GetFilterPropertyType(propertyName)); }