Exemplo n.º 1
0
 public void Patch(string id, [FromBody] MergePatchOrderShipGroupMvoDto value)
 {
     try {
         OrderShipGroupMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderShipGroupMvoApplicationService.When(value as IMergePatchOrderShipGroupMvo);
     } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 2
0
 public IEnumerable <IOrderShipGroupMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrderShipGroupMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _orderShipGroupMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                       , n => (OrderShipGroupMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderShipGroupMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                               , OrderShipGroupMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _orderShipGroupMvoApplicationService.Get(OrderShipGroupMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                               , OrderShipGroupMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrderShipGroupMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderShipGroupMvoStateDtoWrapper ? (OrderShipGroupMvoStateDtoWrapper)s : new OrderShipGroupMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 3
0
 public OrderShipGroupMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrderShipGroupMvosControllerUtils.ParseIdString(id);
         var conv  = new OrderShipGroupMvoStateEventDtoConverter();
         var se    = _orderShipGroupMvoApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrderShipGroupMvoStateEventDto(se));
     } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteOrderShipGroupMvoDto();
         value.CommandId    = commandId;
         value.RequesterId  = requesterId;
         value.OrderVersion = (long)Convert.ChangeType(version, typeof(long));
         OrderShipGroupMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderShipGroupMvoApplicationService.When(value as IDeleteOrderShipGroupMvo);
     } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 5
0
        public HttpResponseMessage Post([FromBody] CreateOrderShipGroupMvoDto value)
        {
            try {
                if (value.OrderShipGroupId == default(OrderShipGroupId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrderShipGroupMvo");
                }
                _orderShipGroupMvoApplicationService.When(value as ICreateOrderShipGroupMvo);
                var idObj = value.OrderShipGroupId;

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

                OrderShipGroupMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderShipGroupMvoApplicationService.When(value as ICreateOrderShipGroupMvo);
            } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Exemplo n.º 9
0
 public IOrderShipGroupMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = OrderShipGroupMvosControllerUtils.ParseIdString(id);
         var state = _orderShipGroupMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderShipGroupMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrderShipGroupMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }