public IEnumerable <IAttributeValueMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IAttributeValueMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _attributeValueMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                               , AttributeValueMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _attributeValueMvoApplicationService.Get(AttributeValueMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                               , AttributeValueMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IAttributeValueMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is AttributeValueMvoStateDtoWrapper ? (AttributeValueMvoStateDtoWrapper)s : new AttributeValueMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Patch(string id, [FromBody] MergePatchAttributeValueMvoDto value)
 {
     try {
         AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeValueMvoApplicationService.When(value as IMergePatchAttributeValueMvo);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IAttributeValueMvoStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = AttributeValueMvosControllerUtils.ParseIdString(id);
         return(_attributeValueMvoApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public AttributeValueMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = AttributeValueMvosControllerUtils.ParseIdString(id);
         var conv  = new AttributeValueMvoStateEventDtoConverter();
         var se    = _attributeValueMvoApplicationService.GetStateEvent(idObj, version);
         return(se == null ? null : conv.ToAttributeValueMvoStateEventDto(se));
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteAttributeValueMvoDto();
         value.CommandId        = commandId;
         value.RequesterId      = requesterId;
         value.AttributeVersion = (long)Convert.ChangeType(version, typeof(long));
         AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeValueMvoApplicationService.When(value as IDeleteAttributeValueMvo);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #6
0
        public HttpResponseMessage Post([FromBody] CreateAttributeValueMvoDto value)
        {
            try {
                if (value.AttributeValueId == default(AttributeValueId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "AttributeValueMvo");
                }
                _attributeValueMvoApplicationService.When(value as ICreateAttributeValueMvo);
                var idObj = value.AttributeValueId;

                return(Request.CreateResponse <AttributeValueId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in AttributeValueMvoMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _attributeValueMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _attributeValueMvoApplicationService.GetCount(AttributeValueMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in AttributeValueMvoMetadata.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 = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #10
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeValueMvoDto value)
        {
            try {
                // ///////////////////////////////
                if (value.AttributeVersion != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _attributeValueMvoApplicationService.When(value as IMergePatchAttributeValueMvo);
                    return;
                }
                // ///////////////////////////////

                AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _attributeValueMvoApplicationService.When(value as ICreateAttributeValueMvo);
            } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public IAttributeValueMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = AttributeValueMvosControllerUtils.ParseIdString(id);
         var state = _attributeValueMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new AttributeValueMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(AttributeValueMvosControllerUtils.GetFilterPropertyType(propertyName));
 }