public async Task WhenAsync(MergePatchOrderShipmentDto c)
        {
            var idObj         = OrderShipmentProxyUtils.ToIdString((c as IMergePatchOrderShipment).OrderShipmentId);
            var uriParameters = new OrderShipmentUriParameters();

            uriParameters.Id = idObj;

            var req  = new OrderShipmentPatchRequest(uriParameters, (MergePatchOrderShipmentDto)c);
            var resp = await _ramlClient.OrderShipment.Patch(req);

            OrderShipmentProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async Task <IOrderShipmentState> GetHistoryStateAsync(OrderShipmentId orderShipmentId, long version)
        {
            var idObj         = OrderShipmentProxyUtils.ToIdString(orderShipmentId);
            var uriParameters = new OrderShipmentHistoryStateUriParameters();

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

            var req  = new OrderShipmentHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.OrderShipmentHistoryState.Get(req);

            OrderShipmentProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToOrderShipmentState());
        }
        public async Task <IOrderShipmentEvent> GetStateEventAsync(OrderShipmentId orderShipmentId, long version)
        {
            var idObj         = OrderShipmentProxyUtils.ToIdString(orderShipmentId);
            var uriParameters = new OrderShipmentStateEventUriParameters();

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

            var req  = new OrderShipmentStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.OrderShipmentStateEvent.Get(req);

            OrderShipmentProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IOrderShipmentState> GetAsync(OrderShipmentId orderShipmentId)
        {
            IOrderShipmentState state = null;
            var idObj         = OrderShipmentProxyUtils.ToIdString(orderShipmentId);
            var uriParameters = new OrderShipmentUriParameters();

            uriParameters.Id = idObj;

            var req = new OrderShipmentGetRequest(uriParameters);

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

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

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

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

            OrderShipmentProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToOrderShipmentState());
            return(states);
        }
        public async Task WhenAsync(DeleteOrderShipmentDto c)
        {
            var idObj         = OrderShipmentProxyUtils.ToIdString((c as IDeleteOrderShipment).OrderShipmentId);
            var uriParameters = new OrderShipmentUriParameters();

            uriParameters.Id = idObj;

            var q = new OrderShipmentDeleteQuery();

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

            var req = new OrderShipmentDeleteRequest(uriParameters);

            req.Query = q;

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

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

            q.Filter = OrderShipmentProxyUtils.GetFilterQueryValueString(filter);
            var req = new OrderShipmentsCountGetRequest();

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

            OrderShipmentProxyUtils.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));
        }