示例#1
0
 public void Patch(string id, [FromBody] MergePatchOrderShipmentDto value)
 {
     try {
         OrderShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderShipmentApplicationService.When(value as IMergePatchOrderShipment);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#2
0
 public IEnumerable <IOrderShipmentStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrderShipmentState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _orderShipmentApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                   , n => (OrderShipmentMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderShipmentMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                           , OrderShipmentsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _orderShipmentApplicationService.Get(OrderShipmentsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                           , OrderShipmentsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrderShipmentStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderShipmentStateDtoWrapper ? (OrderShipmentStateDtoWrapper)s : new OrderShipmentStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#3
0
 public OrderShipmentStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrderShipmentsControllerUtils.ParseIdString(id);
         var conv  = new OrderShipmentStateEventDtoConverter();
         var se    = _orderShipmentApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrderShipmentStateEventDto(se));
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#4
0
        public HttpResponseMessage Post([FromBody] CreateOrderShipmentDto value)
        {
            try {
                if (value.OrderShipmentId == default(OrderShipmentId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrderShipment");
                }
                _orderShipmentApplicationService.When(value as ICreateOrderShipment);
                var idObj = value.OrderShipmentId;

                return(Request.CreateResponse <OrderShipmentId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = OrderShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#5
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _orderShipmentApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                       , n => (OrderShipmentMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderShipmentMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _orderShipmentApplicationService.GetCount(OrderShipmentsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#6
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteOrderShipmentDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    OrderShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _orderShipmentApplicationService.When(value as IMergePatchOrderShipment);
                    return;
                }
                // ///////////////////////////////

                OrderShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderShipmentApplicationService.When(value as ICreateOrderShipment);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#7
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in OrderShipmentMetadata.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 = OrderShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#8
0
 public IOrderShipmentStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = OrderShipmentsControllerUtils.ParseIdString(id);
         var state = _orderShipmentApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderShipmentStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#9
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrderShipmentsControllerUtils.GetFilterPropertyType(propertyName));
 }