Exemplo n.º 1
0
 public void Patch(string id, [FromBody] MergePatchMovementConfirmationDto value)
 {
     try {
         MovementConfirmationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _movementConfirmationApplicationService.When(value as IMergePatchMovementConfirmation);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 2
0
 public IEnumerable <IMovementConfirmationStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IMovementConfirmationState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _movementConfirmationApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                          , n => (MovementConfirmationMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? MovementConfirmationMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                  , MovementConfirmationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _movementConfirmationApplicationService.Get(MovementConfirmationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                  , MovementConfirmationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IMovementConfirmationStateDto>();
         foreach (var s in states)
         {
             var dto = s is MovementConfirmationStateDtoWrapper ? (MovementConfirmationStateDtoWrapper)s : new MovementConfirmationStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 3
0
 public MovementConfirmationStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new MovementConfirmationStateEventDtoConverter();
         var se    = _movementConfirmationApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToMovementConfirmationStateEventDto(se));
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteMovementConfirmationDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         MovementConfirmationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _movementConfirmationApplicationService.When(value as IDeleteMovementConfirmation);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 5
0
 public IMovementConfirmationLineStateDto GetMovementConfirmationLine(string movementConfirmationDocumentNumber, string lineNumber)
 {
     try {
         var state = (MovementConfirmationLineState)_movementConfirmationApplicationService.GetMovementConfirmationLine(movementConfirmationDocumentNumber, lineNumber);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new MovementConfirmationLineStateDtoWrapper(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 6
0
        public HttpResponseMessage Post([FromBody] CreateMovementConfirmationDto value)
        {
            try {
                if (value.DocumentNumber == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "MovementConfirmation");
                }
                _movementConfirmationApplicationService.When(value as ICreateMovementConfirmation);
                var idObj = value.DocumentNumber;

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

                MovementConfirmationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _movementConfirmationApplicationService.When(value as ICreateMovementConfirmation);
            } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Exemplo n.º 11
0
 public IEnumerable <IMovementConfirmationLineStateDto> GetMovementConfirmationLines(string movementConfirmationDocumentNumber)
 {
     try {
         var states = _movementConfirmationApplicationService.GetMovementConfirmationLines(movementConfirmationDocumentNumber);
         if (states == null)
         {
             return(null);
         }
         var stateDtos = new List <IMovementConfirmationLineStateDto>();
         foreach (var s in states)
         {
             var dto = s is MovementConfirmationLineStateDtoWrapper ? (MovementConfirmationLineStateDtoWrapper)s : new MovementConfirmationLineStateDtoWrapper((MovementConfirmationLineState)s);
             dto.AllFieldsReturned = true;
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 12
0
 public IMovementConfirmationStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _movementConfirmationApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new MovementConfirmationStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Exemplo n.º 13
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(MovementConfirmationsControllerUtils.GetFilterPropertyType(propertyName));
 }