示例#1
0
 public void Patch(string id, [FromBody] MergePatchOrderDto value)
 {
     try {
         OrdersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderApplicationService.When(value as IMergePatchOrder);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#2
0
 public IEnumerable <IOrderStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrderState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _orderApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                           , n => (OrderMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                   , OrdersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _orderApplicationService.Get(OrdersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                   , OrdersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrderStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderStateDtoWrapper ? (OrderStateDtoWrapper)s : new OrderStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#3
0
 public OrderStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new OrderStateEventDtoConverter();
         var se    = _orderApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrderStateEventDto(se));
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#4
0
 public IOrderItemShipGroupAssociationStateDto GetOrderItemShipGroupAssociation(string orderId, long?orderShipGroupShipGroupSeqId, string orderItemSeqId)
 {
     try {
         var state = (OrderItemShipGroupAssociationState)_orderApplicationService.GetOrderItemShipGroupAssociation(orderId, orderShipGroupShipGroupSeqId, orderItemSeqId);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderItemShipGroupAssociationStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#5
0
 public IOrderRoleStateDto GetOrderRole(string orderId, string partyRoleId)
 {
     try {
         var state = (OrderRoleState)_orderApplicationService.GetOrderRole(orderId, ((new ValueObjectTextFormatter <PartyRoleId>()).Parse(partyRoleId)));
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderRoleStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#6
0
        public HttpResponseMessage Post([FromBody] CreateOrderDto value)
        {
            try {
                if (value.OrderId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Order");
                }
                _orderApplicationService.When(value as ICreateOrder);
                var idObj = value.OrderId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#7
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _orderApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                               , n => (OrderMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _orderApplicationService.GetCount(OrdersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#8
0
 public void OrderShipGroupAction(string orderId, long?shipGroupSeqId, [FromBody] OrderCommandDtos.OrderShipGroupActionRequestContent content)
 {
     try {
         var cmd   = content.ToOrderShipGroupAction();
         var idObj = new OrderShipGroupId(orderId, shipGroupSeqId);
         if (cmd.OrderShipGroupId == null)
         {
             cmd.OrderShipGroupId = idObj;
         }
         else if (!cmd.OrderShipGroupId.Equals(idObj))
         {
             throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", idObj, cmd.OrderShipGroupId);
         }
         _orderApplicationService.When(cmd);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#9
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in OrderMetadata.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 = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#10
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteOrderDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    OrdersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _orderApplicationService.When(value as IMergePatchOrder);
                    return;
                }
                // ///////////////////////////////

                OrdersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderApplicationService.When(value as ICreateOrder);
            } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#11
0
 public IEnumerable <IOrderItemShipGroupAssociationStateDto> GetOrderItemShipGroupAssociations(string orderId, long?orderShipGroupShipGroupSeqId)
 {
     try {
         var states = _orderApplicationService.GetOrderItemShipGroupAssociations(orderId, orderShipGroupShipGroupSeqId);
         if (states == null)
         {
             return(null);
         }
         var stateDtos = new List <IOrderItemShipGroupAssociationStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderItemShipGroupAssociationStateDtoWrapper ? (OrderItemShipGroupAssociationStateDtoWrapper)s : new OrderItemShipGroupAssociationStateDtoWrapper((OrderItemShipGroupAssociationState)s);
             dto.AllFieldsReturned = true;
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#12
0
 public IOrderStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _orderApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#13
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrdersControllerUtils.GetFilterPropertyType(propertyName));
 }