Ejemplo n.º 1
0
 public IEnumerable <IOrderRoleMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrderRoleMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _orderRoleMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                  , n => (OrderRoleMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrderRoleMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                          , OrderRoleMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _orderRoleMvoApplicationService.Get(OrderRoleMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                          , OrderRoleMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrderRoleMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrderRoleMvoStateDtoWrapper ? (OrderRoleMvoStateDtoWrapper)s : new OrderRoleMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 2
0
 public void Patch(string id, [FromBody] MergePatchOrderRoleMvoDto value)
 {
     try {
         OrderRoleMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderRoleMvoApplicationService.When(value as IMergePatchOrderRoleMvo);
     } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 3
0
 public OrderRoleMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrderRoleMvosControllerUtils.ParseIdString(id);
         var conv  = new OrderRoleMvoStateEventDtoConverter();
         var se    = _orderRoleMvoApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrderRoleMvoStateEventDto(se));
     } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteOrderRoleMvoDto();
         value.CommandId    = commandId;
         value.RequesterId  = requesterId;
         value.OrderVersion = (long)Convert.ChangeType(version, typeof(long));
         OrderRoleMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _orderRoleMvoApplicationService.When(value as IDeleteOrderRoleMvo);
     } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 5
0
        public HttpResponseMessage Post([FromBody] CreateOrderRoleMvoDto value)
        {
            try {
                if (value.OrderRoleId == default(OrderRoleId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrderRoleMvo");
                }
                _orderRoleMvoApplicationService.When(value as ICreateOrderRoleMvo);
                var idObj = value.OrderRoleId;

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

                OrderRoleMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderRoleMvoApplicationService.When(value as ICreateOrderRoleMvo);
            } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Ejemplo n.º 9
0
 public IOrderRoleMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = OrderRoleMvosControllerUtils.ParseIdString(id);
         var state = _orderRoleMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrderRoleMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrderRoleMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 10
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrderRoleMvosControllerUtils.GetFilterPropertyType(propertyName));
 }