public void Patch(string id, [FromBody] MergePatchShipmentPackageContentMvoDto value)
 {
     try {
         ShipmentPackageContentMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _shipmentPackageContentMvoApplicationService.When(value as IMergePatchShipmentPackageContentMvo);
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <IShipmentPackageContentMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IShipmentPackageContentMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _shipmentPackageContentMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                               , n => (ShipmentPackageContentMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentPackageContentMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                       , ShipmentPackageContentMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _shipmentPackageContentMvoApplicationService.Get(ShipmentPackageContentMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                       , ShipmentPackageContentMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IShipmentPackageContentMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is ShipmentPackageContentMvoStateDtoWrapper ? (ShipmentPackageContentMvoStateDtoWrapper)s : new ShipmentPackageContentMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public ShipmentPackageContentMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = ShipmentPackageContentMvosControllerUtils.ParseIdString(id);
         var conv  = new ShipmentPackageContentMvoStateEventDtoConverter();
         var se    = _shipmentPackageContentMvoApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToShipmentPackageContentMvoStateEventDto(se));
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteShipmentPackageContentMvoDto();
         value.CommandId              = commandId;
         value.RequesterId            = requesterId;
         value.ShipmentPackageVersion = (long)Convert.ChangeType(version, typeof(long));
         ShipmentPackageContentMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _shipmentPackageContentMvoApplicationService.When(value as IDeleteShipmentPackageContentMvo);
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
        public HttpResponseMessage Post([FromBody] CreateShipmentPackageContentMvoDto value)
        {
            try {
                if (value.ShipmentPackageContentId == default(ShipmentPackageContentId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "ShipmentPackageContentMvo");
                }
                _shipmentPackageContentMvoApplicationService.When(value as ICreateShipmentPackageContentMvo);
                var idObj = value.ShipmentPackageContentId;

                return(Request.CreateResponse <ShipmentPackageContentId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _shipmentPackageContentMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                   , n => (ShipmentPackageContentMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentPackageContentMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _shipmentPackageContentMvoApplicationService.GetCount(ShipmentPackageContentMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in ShipmentPackageContentMvoMetadata.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 = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentPackageContentMvoDto value)
        {
            try {
                // ///////////////////////////////
                if (value.ShipmentPackageVersion != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    ShipmentPackageContentMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _shipmentPackageContentMvoApplicationService.When(value as IMergePatchShipmentPackageContentMvo);
                    return;
                }
                // ///////////////////////////////

                ShipmentPackageContentMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _shipmentPackageContentMvoApplicationService.When(value as ICreateShipmentPackageContentMvo);
            } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public IShipmentPackageContentMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = ShipmentPackageContentMvosControllerUtils.ParseIdString(id);
         var state = _shipmentPackageContentMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new ShipmentPackageContentMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = ShipmentPackageContentMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }