Пример #1
0
 public void Patch(string id, [FromBody] MergePatchPhysicalInventoryDto value)
 {
     try {
         PhysicalInventoriesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _physicalInventoryApplicationService.When(value as IMergePatchPhysicalInventory);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #2
0
 public IEnumerable <IPhysicalInventoryStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPhysicalInventoryState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _physicalInventoryApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                       , n => (PhysicalInventoryMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PhysicalInventoryMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                               , PhysicalInventoriesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _physicalInventoryApplicationService.Get(PhysicalInventoriesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                               , PhysicalInventoriesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IPhysicalInventoryStateDto>();
         foreach (var s in states)
         {
             var dto = s is PhysicalInventoryStateDtoWrapper ? (PhysicalInventoryStateDtoWrapper)s : new PhysicalInventoryStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #3
0
 public PhysicalInventoryStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new PhysicalInventoryStateEventDtoConverter();
         var se    = _physicalInventoryApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToPhysicalInventoryStateEventDto(se));
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #4
0
 public IPhysicalInventoryLineStateDto GetPhysicalInventoryLine(string physicalInventoryDocumentNumber, string inventoryItemId)
 {
     try {
         var state = (PhysicalInventoryLineState)_physicalInventoryApplicationService.GetPhysicalInventoryLine(physicalInventoryDocumentNumber, ((new ValueObjectTextFormatter <InventoryItemId>()).Parse(inventoryItemId)));
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PhysicalInventoryLineStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #5
0
        public HttpResponseMessage Post([FromBody] CreatePhysicalInventoryDto value)
        {
            try {
                if (value.DocumentNumber == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "PhysicalInventory");
                }
                _physicalInventoryApplicationService.When(value as ICreatePhysicalInventory);
                var idObj = value.DocumentNumber;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Пример #6
0
 public void DocumentAction(string id, [FromBody] PhysicalInventoryCommandDtos.DocumentActionRequestContent content)
 {
     try {
         var cmd   = content.ToDocumentAction();
         var idObj = id;
         if (cmd.DocumentNumber == null)
         {
             cmd.DocumentNumber = idObj;
         }
         else if (!cmd.DocumentNumber.Equals(idObj))
         {
             throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, cmd.DocumentNumber);
         }
         _physicalInventoryApplicationService.When(cmd);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #7
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _physicalInventoryApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                           , n => (PhysicalInventoryMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PhysicalInventoryMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _physicalInventoryApplicationService.GetCount(PhysicalInventoriesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #8
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in PhysicalInventoryMetadata.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 = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #9
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePhysicalInventoryDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    PhysicalInventoriesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _physicalInventoryApplicationService.When(value as IMergePatchPhysicalInventory);
                    return;
                }
                // ///////////////////////////////

                PhysicalInventoriesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _physicalInventoryApplicationService.When(value as ICreatePhysicalInventory);
            } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Пример #10
0
 public IEnumerable <IPhysicalInventoryLineStateDto> GetPhysicalInventoryLines(string physicalInventoryDocumentNumber)
 {
     try {
         var states = _physicalInventoryApplicationService.GetPhysicalInventoryLines(physicalInventoryDocumentNumber);
         if (states == null)
         {
             return(null);
         }
         var stateDtos = new List <IPhysicalInventoryLineStateDto>();
         foreach (var s in states)
         {
             var dto = s is PhysicalInventoryLineStateDtoWrapper ? (PhysicalInventoryLineStateDtoWrapper)s : new PhysicalInventoryLineStateDtoWrapper((IPhysicalInventoryLineState)s);
             dto.AllFieldsReturned = true;
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Пример #11
0
 public IPhysicalInventoryStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _physicalInventoryApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PhysicalInventoryStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = PhysicalInventoriesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }