Beispiel #1
0
 public void Patch(string id, [FromBody] MergePatchOrderItemMvoDto value)
 {
     try {
         OrderItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderItemMvoApplicationService.When(value as IMergePatchOrderItemMvo);
     } catch (Exception ex) { var response = OrderItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #2
0
 public IEnumerable <IOrderItemMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrderItemMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _orderItemMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                  , n => (OrderItemMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderItemMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                          , OrderItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _orderItemMvoApplicationService.Get(OrderItemMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                          , OrderItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrderItemMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderItemMvoStateDtoWrapper ? (OrderItemMvoStateDtoWrapper)s : new OrderItemMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrderItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #3
0
 public OrderItemMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrderItemMvosControllerUtils.ParseIdString(id);
         var conv  = new OrderItemMvoStateEventDtoConverter();
         var se    = _orderItemMvoApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrderItemMvoStateEventDto(se));
     } catch (Exception ex) { var response = OrderItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #4
0
        public HttpResponseMessage Post([FromBody] CreateOrderItemMvoDto value)
        {
            try {
                if (value.OrderItemId == default(OrderItemId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrderItemMvo");
                }
                _orderItemMvoApplicationService.When(value as ICreateOrderItemMvo);
                var idObj = value.OrderItemId;

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

                OrderItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderItemMvoApplicationService.When(value as ICreateOrderItemMvo);
            } catch (Exception ex) { var response = OrderItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Beispiel #8
0
 public IOrderItemMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = OrderItemMvosControllerUtils.ParseIdString(id);
         var state = _orderItemMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderItemMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrderItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #9
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrderItemMvosControllerUtils.GetFilterPropertyType(propertyName));
 }