예제 #1
0
 public IEnumerable <AttributeUseMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IAttributeUseMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _attributeUseMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                             , AttributeUseMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _attributeUseMvoApplicationService.Get(AttributeUseMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                             , AttributeUseMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <AttributeUseMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is AttributeUseMvoStateDto ? (AttributeUseMvoStateDto)s : new AttributeUseMvoStateDto((AttributeUseMvoState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #2
0
 public IAttributeUseMvoStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = AttributeUseMvosControllerUtils.ParseIdString(id);
         return(_attributeUseMvoApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #3
0
 public void Patch(string id, [FromBody] MergePatchAttributeUseMvoDto value)
 {
     try {
         AttributeUseMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeUseMvoApplicationService.When(value as IMergePatchAttributeUseMvo);
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #4
0
 public AttributeUseMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = AttributeUseMvosControllerUtils.ParseIdString(id);
         var conv  = new AttributeUseMvoStateEventDtoConverter();
         var se    = _attributeUseMvoApplicationService.GetStateEvent(idObj, version);
         return(se == null ? null : conv.ToAttributeUseMvoStateEventDto(se));
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #5
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteAttributeUseMvoDto();
         value.CommandId           = commandId;
         value.RequesterId         = requesterId;
         value.AttributeSetVersion = (long)Convert.ChangeType(version, typeof(long));
         AttributeUseMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeUseMvoApplicationService.When(value as IDeleteAttributeUseMvo);
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #6
0
        public HttpResponseMessage Post([FromBody] CreateAttributeUseMvoDto value)
        {
            try {
                if (value.AttributeSetAttributeUseId == default(AttributeSetAttributeUseId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "AttributeUseMvo");
                }
                _attributeUseMvoApplicationService.When(value as ICreateAttributeUseMvo);
                var idObj = value.AttributeSetAttributeUseId;

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

                AttributeUseMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _attributeUseMvoApplicationService.When(value as ICreateAttributeUseMvo);
            } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
예제 #11
0
 public AttributeUseMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = AttributeUseMvosControllerUtils.ParseIdString(id);
         var state = (AttributeUseMvoState)_attributeUseMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new AttributeUseMvoStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = AttributeUseMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #12
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(AttributeUseMvosControllerUtils.GetFilterPropertyType(propertyName));
 }