コード例 #1
0
 public IEnumerable <IPicklistItemMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPicklistItemMvoState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _picklistItemMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                     , n => (PicklistItemMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PicklistItemMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                             , PicklistItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _picklistItemMvoApplicationService.Get(PicklistItemMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                             , PicklistItemMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IPicklistItemMvoStateDto>();
         foreach (var s in states)
         {
             var dto = s is PicklistItemMvoStateDtoWrapper ? (PicklistItemMvoStateDtoWrapper)s : new PicklistItemMvoStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #2
0
 public void Patch(string id, [FromBody] MergePatchPicklistItemMvoDto value)
 {
     try {
         PicklistItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _picklistItemMvoApplicationService.When(value as IMergePatchPicklistItemMvo);
     } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #3
0
 public PicklistItemMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = PicklistItemMvosControllerUtils.ParseIdString(id);
         var conv  = new PicklistItemMvoStateEventDtoConverter();
         var se    = _picklistItemMvoApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToPicklistItemMvoStateEventDto(se));
     } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeletePicklistItemMvoDto();
         value.CommandId          = commandId;
         value.RequesterId        = requesterId;
         value.PicklistBinVersion = (long)Convert.ChangeType(version, typeof(long));
         PicklistItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _picklistItemMvoApplicationService.When(value as IDeletePicklistItemMvo);
     } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #5
0
        public HttpResponseMessage Post([FromBody] CreatePicklistItemMvoDto value)
        {
            try {
                if (value.PicklistBinPicklistItemId == default(PicklistBinPicklistItemId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "PicklistItemMvo");
                }
                _picklistItemMvoApplicationService.When(value as ICreatePicklistItemMvo);
                var idObj = value.PicklistBinPicklistItemId;

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

                PicklistItemMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _picklistItemMvoApplicationService.When(value as ICreatePicklistItemMvo);
            } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
コード例 #9
0
 public IPicklistItemMvoStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = PicklistItemMvosControllerUtils.ParseIdString(id);
         var state = _picklistItemMvoApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PicklistItemMvoStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = PicklistItemMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
コード例 #10
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(PicklistItemMvosControllerUtils.GetFilterPropertyType(propertyName));
 }