コード例 #1
0
 public JArray GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IAttributeSetInstanceState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _attributeSetInstanceApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                                  , AttributeSetInstancesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _attributeSetInstanceApplicationService.Get(AttributeSetInstancesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                  , AttributeSetInstancesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         JArray dynamicArray = new JArray();
         foreach (var s in states)
         {
             var dto = s is AttributeSetInstanceStateDto ? (AttributeSetInstanceStateDto)s : new AttributeSetInstanceStateDto((AttributeSetInstanceState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             dynamicArray.Add(_attributeSetInstanceDtoJObjectMapper.MapState(dto));
         }
         return(dynamicArray);
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #2
0
 public IAttributeSetInstanceStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         return(_attributeSetInstanceApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #3
0
 public void Patch(string id, [FromBody] JObject dynamicObject)
 {
     try {
         MergePatchAttributeSetInstanceDto value = _attributeSetInstanceDtoJObjectMapper.ToCommandMergePatch(dynamicObject);
         AttributeSetInstancesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeSetInstanceApplicationService.When(value as IMergePatchAttributeSetInstance);
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #4
0
 public AttributeSetInstanceStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new AttributeSetInstanceStateEventDtoConverter();
         var se    = _attributeSetInstanceApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToAttributeSetInstanceStateEventDto(se));
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #5
0
        public HttpResponseMessage Post([FromBody] JObject dynamicObject)
        {
            try {
                CreateAttributeSetInstanceDto value = _attributeSetInstanceDtoJObjectMapper.ToCommandCreate(dynamicObject);
                var idObj = _attributeSetInstanceApplicationService.CreateWithoutId(value as ICreateAttributeSetInstance);

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
コード例 #6
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteAttributeSetInstanceDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         AttributeSetInstancesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeSetInstanceApplicationService.When(value as IDeleteAttributeSetInstance);
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #7
0
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in AttributeSetInstanceMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #8
0
        public HttpResponseMessage Post([FromBody] JObject dynamicObject)
        {
            try {
                CreateAttributeSetInstanceDto value = _attributeSetInstanceDtoJObjectMapper.ToCommandCreate(dynamicObject);
                bool   reused;
                string idObj = _attributeSetInstanceIdGenerator.GetOrGenerateId(value, out reused);
                if (!reused)
                {
                    ((ICreateOrMergePatchOrDeleteAttributeSetInstance)value).AttributeSetInstanceId = idObj;
                    _attributeSetInstanceApplicationService.When(value as ICreateAttributeSetInstance);
                }

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
コード例 #9
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _attributeSetInstanceApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _attributeSetInstanceApplicationService.GetCount(AttributeSetInstancesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #10
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in AttributeSetInstanceMetadata.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 = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #11
0
 public JObject Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = (AttributeSetInstanceState)_attributeSetInstanceApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new AttributeSetInstanceStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(_attributeSetInstanceDtoJObjectMapper.MapState(stateDto));
     } catch (Exception ex) { var response = AttributeSetInstancesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #12
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(AttributeSetInstancesControllerUtils.GetFilterPropertyType(propertyName));
 }