Esempio n. 1
0
 public void Patch(string id, [FromBody] MergePatchInventoryItemRequirementDto value)
 {
     try {
         InventoryItemRequirementsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _inventoryItemRequirementApplicationService.When(value as IMergePatchInventoryItemRequirement);
     } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 2
0
 public IEnumerable <IInventoryItemRequirementStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IInventoryItemRequirementState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _inventoryItemRequirementApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                              , n => (InventoryItemRequirementMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryItemRequirementMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                      , InventoryItemRequirementsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _inventoryItemRequirementApplicationService.Get(InventoryItemRequirementsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                      , InventoryItemRequirementsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IInventoryItemRequirementStateDto>();
         foreach (var s in states)
         {
             var dto = s is InventoryItemRequirementStateDtoWrapper ? (InventoryItemRequirementStateDtoWrapper)s : new InventoryItemRequirementStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 3
0
 public IInventoryItemRequirementEntryStateDto GetInventoryItemRequirementEntry(string inventoryItemRequirementId, long entrySeqId)
 {
     try {
         var state = (InventoryItemRequirementEntryState)_inventoryItemRequirementApplicationService.GetInventoryItemRequirementEntry(((new ValueObjectTextFormatter <InventoryItemId>()).Parse(inventoryItemRequirementId)), entrySeqId);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new InventoryItemRequirementEntryStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 4
0
        public HttpResponseMessage Post([FromBody] CreateInventoryItemRequirementDto value)
        {
            try {
                if (value.InventoryItemRequirementId == default(InventoryItemId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "InventoryItemRequirement");
                }
                _inventoryItemRequirementApplicationService.When(value as ICreateInventoryItemRequirement);
                var idObj = value.InventoryItemRequirementId;

                return(Request.CreateResponse <InventoryItemId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _inventoryItemRequirementApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                  , n => (InventoryItemRequirementMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? InventoryItemRequirementMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _inventoryItemRequirementApplicationService.GetCount(InventoryItemRequirementsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 6
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in InventoryItemRequirementMetadata.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 = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 7
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteInventoryItemRequirementDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    InventoryItemRequirementsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _inventoryItemRequirementApplicationService.When(value as IMergePatchInventoryItemRequirement);
                    return;
                }
                // ///////////////////////////////

                InventoryItemRequirementsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _inventoryItemRequirementApplicationService.When(value as ICreateInventoryItemRequirement);
            } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Esempio n. 8
0
 public IEnumerable <IInventoryItemRequirementEntryStateDto> GetInventoryItemRequirementEntries(string inventoryItemRequirementId)
 {
     try {
         var states = _inventoryItemRequirementApplicationService.GetInventoryItemRequirementEntries(((new ValueObjectTextFormatter <InventoryItemId>()).Parse(inventoryItemRequirementId)));
         if (states == null)
         {
             return(null);
         }
         var stateDtos = new List <IInventoryItemRequirementEntryStateDto>();
         foreach (var s in states)
         {
             var dto = s is InventoryItemRequirementEntryStateDtoWrapper ? (InventoryItemRequirementEntryStateDtoWrapper)s : new InventoryItemRequirementEntryStateDtoWrapper((InventoryItemRequirementEntryState)s);
             dto.AllFieldsReturned = true;
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 9
0
 public IInventoryItemRequirementStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = InventoryItemRequirementsControllerUtils.ParseIdString(id);
         var state = _inventoryItemRequirementApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new InventoryItemRequirementStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 10
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(InventoryItemRequirementsControllerUtils.GetFilterPropertyType(propertyName));
 }