public void Patch(string id, [FromBody] MergePatchGoodIdentificationTypeDto value)
 {
     try {
         GoodIdentificationTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _goodIdentificationTypeApplicationService.When(value as IMergePatchGoodIdentificationType);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <IGoodIdentificationTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IGoodIdentificationTypeState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _goodIdentificationTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                            , n => (GoodIdentificationTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? GoodIdentificationTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                    , GoodIdentificationTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _goodIdentificationTypeApplicationService.Get(GoodIdentificationTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                    , GoodIdentificationTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IGoodIdentificationTypeStateDto>();
         foreach (var s in states)
         {
             var dto = s is GoodIdentificationTypeStateDtoWrapper ? (GoodIdentificationTypeStateDtoWrapper)s : new GoodIdentificationTypeStateDtoWrapper(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); }
 }
示例#3
0
 public GoodIdentificationTypeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new GoodIdentificationTypeStateEventDtoConverter();
         var se    = _goodIdentificationTypeApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToGoodIdentificationTypeStateEventDto(se));
     } catch (Exception ex) { var response = GoodIdentificationTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteGoodIdentificationTypeDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         GoodIdentificationTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _goodIdentificationTypeApplicationService.When(value as IDeleteGoodIdentificationType);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#5
0
        public HttpResponseMessage Post([FromBody] CreateGoodIdentificationTypeDto value)
        {
            try {
                if (value.GoodIdentificationTypeId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "GoodIdentificationType");
                }
                _goodIdentificationTypeApplicationService.When(value as ICreateGoodIdentificationType);
                var idObj = value.GoodIdentificationTypeId;

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

                GoodIdentificationTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _goodIdentificationTypeApplicationService.When(value as ICreateGoodIdentificationType);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#8
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in GoodIdentificationTypeMetadata.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 = GoodIdentificationTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#9
0
 public IGoodIdentificationTypeStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _goodIdentificationTypeApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new GoodIdentificationTypeStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = GoodIdentificationTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(GoodIdentificationTypesControllerUtils.GetFilterPropertyType(propertyName));
 }