Ejemplo n.º 1
0
 public void Patch(string id, [FromBody] MergePatchPicklistBinDto value)
 {
     try {
         PicklistBinsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _picklistBinApplicationService.When(value as IMergePatchPicklistBin);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 2
0
 public IEnumerable <IPicklistBinStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPicklistBinState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _picklistBinApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                 , n => (PicklistBinMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PicklistBinMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                         , PicklistBinsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _picklistBinApplicationService.Get(PicklistBinsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                         , PicklistBinsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IPicklistBinStateDto>();
         foreach (var s in states)
         {
             var dto = s is PicklistBinStateDtoWrapper ? (PicklistBinStateDtoWrapper)s : new PicklistBinStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 3
0
 public PicklistBinStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new PicklistBinStateEventDtoConverter();
         var se    = _picklistBinApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToPicklistBinStateEventDto(se));
     } catch (Exception ex) { var response = PicklistBinsControllerUtils.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 DeletePicklistBinDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         PicklistBinsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _picklistBinApplicationService.When(value as IDeletePicklistBin);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 5
0
 public IPicklistItemStateDto GetPicklistItem(string picklistBinId, string picklistItemOrderShipGrpInvId)
 {
     try {
         var state = (PicklistItemState)_picklistBinApplicationService.GetPicklistItem(picklistBinId, ((new ValueObjectTextFormatter <PicklistItemOrderShipGrpInvId>()).Parse(picklistItemOrderShipGrpInvId)));
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PicklistItemStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = PicklistBinsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 6
0
        public HttpResponseMessage Post([FromBody] CreatePicklistBinDto value)
        {
            try {
                if (value.PicklistBinId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "PicklistBin");
                }
                _picklistBinApplicationService.When(value as ICreatePicklistBin);
                var idObj = value.PicklistBinId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = PicklistBinsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Ejemplo n.º 7
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _picklistBinApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                     , n => (PicklistBinMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PicklistBinMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _picklistBinApplicationService.GetCount(PicklistBinsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 8
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePicklistBinDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    PicklistBinsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _picklistBinApplicationService.When(value as IMergePatchPicklistBin);
                    return;
                }
                // ///////////////////////////////

                PicklistBinsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _picklistBinApplicationService.When(value as ICreatePicklistBin);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Ejemplo n.º 9
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in PicklistBinMetadata.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 = PicklistBinsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 10
0
 public IEnumerable <IPicklistItemStateDto> GetPicklistItems(string picklistBinId)
 {
     try {
         var states = _picklistBinApplicationService.GetPicklistItems(picklistBinId);
         if (states == null)
         {
             return(null);
         }
         var stateDtos = new List <IPicklistItemStateDto>();
         foreach (var s in states)
         {
             var dto = s is PicklistItemStateDtoWrapper ? (PicklistItemStateDtoWrapper)s : new PicklistItemStateDtoWrapper((PicklistItemState)s);
             dto.AllFieldsReturned = true;
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PicklistBinsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 11
0
 public IPicklistBinStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _picklistBinApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PicklistBinStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = PicklistBinsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 12
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(PicklistBinsControllerUtils.GetFilterPropertyType(propertyName));
 }