public async Task WhenAsync(MergePatchShipmentTypeDto c)
        {
            var idObj         = (c as IMergePatchShipmentType).ShipmentTypeId;
            var uriParameters = new ShipmentTypeUriParameters();

            uriParameters.Id = idObj;

            var req  = new ShipmentTypePatchRequest(uriParameters, (MergePatchShipmentTypeDto)c);
            var resp = await _ramlClient.ShipmentType.Patch(req);

            ShipmentTypeProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async Task <IShipmentTypeState> GetHistoryStateAsync(string shipmentTypeId, long version)
        {
            var idObj         = shipmentTypeId;
            var uriParameters = new ShipmentTypeHistoryStateUriParameters();

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

            var req  = new ShipmentTypeHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.ShipmentTypeHistoryState.Get(req);

            ShipmentTypeProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToShipmentTypeState());
        }
        public async Task <IShipmentTypeEvent> GetStateEventAsync(string shipmentTypeId, long version)
        {
            var idObj         = shipmentTypeId;
            var uriParameters = new ShipmentTypeStateEventUriParameters();

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

            var req  = new ShipmentTypeStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.ShipmentTypeStateEvent.Get(req);

            ShipmentTypeProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IShipmentTypeState> GetAsync(string shipmentTypeId)
        {
            IShipmentTypeState state = null;
            var idObj         = shipmentTypeId;
            var uriParameters = new ShipmentTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new ShipmentTypeGetRequest(uriParameters);

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

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

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

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

            ShipmentTypeProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToShipmentTypeState());
            return(states);
        }
        public async Task WhenAsync(DeleteShipmentTypeDto c)
        {
            var idObj         = (c as IDeleteShipmentType).ShipmentTypeId;
            var uriParameters = new ShipmentTypeUriParameters();

            uriParameters.Id = idObj;

            var q = new ShipmentTypeDeleteQuery();

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

            var req = new ShipmentTypeDeleteRequest(uriParameters);

            req.Query = q;

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

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

            q.Filter = ShipmentTypeProxyUtils.GetFilterQueryValueString(filter);
            var req = new ShipmentTypesCountGetRequest();

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

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