public async Task WhenAsync(MergePatchMovementConfirmationDto c)
        {
            var idObj         = (c as IMergePatchMovementConfirmation).DocumentNumber;
            var uriParameters = new MovementConfirmationUriParameters();

            uriParameters.Id = idObj;

            var req  = new MovementConfirmationPatchRequest(uriParameters, (MergePatchMovementConfirmationDto)c);
            var resp = await _ramlClient.MovementConfirmation.Patch(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async virtual Task <IMovementConfirmationLineState> GetMovementConfirmationLineAsync(string movementConfirmationDocumentNumber, string lineNumber)
        {
            var uriParameters = new MovementConfirmationLineUriParameters();

            uriParameters.MovementConfirmationDocumentNumber = movementConfirmationDocumentNumber;
            uriParameters.LineNumber = lineNumber;

            var req  = new MovementConfirmationLineGetRequest(uriParameters);
            var resp = await _ramlClient.MovementConfirmationLine.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToMovementConfirmationLineState());
        }
        public async Task <IMovementConfirmationState> GetHistoryStateAsync(string documentNumber, long version)
        {
            var idObj         = documentNumber;
            var uriParameters = new MovementConfirmationHistoryStateUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new MovementConfirmationHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.MovementConfirmationHistoryState.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToMovementConfirmationState());
        }
        public async Task <IMovementConfirmationEvent> GetStateEventAsync(string documentNumber, long version)
        {
            var idObj         = documentNumber;
            var uriParameters = new MovementConfirmationStateEventUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new MovementConfirmationStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.MovementConfirmationStateEvent.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IMovementConfirmationState> GetAsync(string documentNumber)
        {
            IMovementConfirmationState state = null;
            var idObj         = documentNumber;
            var uriParameters = new MovementConfirmationUriParameters();

            uriParameters.Id = idObj;

            var req = new MovementConfirmationGetRequest(uriParameters);

            var resp = await _ramlClient.MovementConfirmation.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToMovementConfirmationState();
            return(state);
        }
        public async Task <IEnumerable <IMovementConfirmationState> > GetAsync(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue, IList <string> fields = null)
        {
            IEnumerable <IMovementConfirmationState> states = null;
            var q = new MovementConfirmationsGetQuery();

            q.FirstResult = firstResult;
            q.MaxResults  = maxResults;
            q.Sort        = MovementConfirmationProxyUtils.GetOrdersQueryValueString(orders);
            q.Fields      = MovementConfirmationProxyUtils.GetReturnedFieldsQueryValueString(fields, QueryFieldValueSeparator);
            q.Filter      = MovementConfirmationProxyUtils.GetFilterQueryValueString(filter);
            var req = new MovementConfirmationsGetRequest();

            req.Query = q;
            var resp = await _ramlClient.MovementConfirmations.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToMovementConfirmationState());
            return(states);
        }
        public async Task WhenAsync(DeleteMovementConfirmationDto c)
        {
            var idObj         = (c as IDeleteMovementConfirmation).DocumentNumber;
            var uriParameters = new MovementConfirmationUriParameters();

            uriParameters.Id = idObj;

            var q = new MovementConfirmationDeleteQuery();

            q.CommandId   = c.CommandId;
            q.RequesterId = c.RequesterId;
            q.Version     = Convert.ToString(c.Version);

            var req = new MovementConfirmationDeleteRequest(uriParameters);

            req.Query = q;

            var resp = await _ramlClient.MovementConfirmation.Delete(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async virtual Task <long> GetCountAsync(ICriterion filter)
        {
            var q = new MovementConfirmationsCountGetQuery();

            q.Filter = MovementConfirmationProxyUtils.GetFilterQueryValueString(filter);
            var req = new MovementConfirmationsCountGetRequest();

            req.Query = q;
            var resp = await _ramlClient.MovementConfirmationsCount.Get(req);

            MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp);
            string str = await resp.RawContent.ReadAsStringAsync();

            if (str.StartsWith("\""))
            {
                str = str.Substring(1);
            }
            if (str.EndsWith("\""))
            {
                str = str.Substring(0, str.Length - 1);
            }
            return(long.Parse(str));
        }