public async Task WhenAsync(MergePatchWarehouseDto c)
        {
            var idObj         = (c as IMergePatchWarehouse).WarehouseId;
            var uriParameters = new WarehouseUriParameters();

            uriParameters.Id = idObj;

            var req  = new WarehousePatchRequest(uriParameters, (MergePatchWarehouseDto)c);
            var resp = await _ramlClient.Warehouse.Patch(req);

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

            q.Filter = WarehouseProxyUtils.GetFilterQueryValueString(filter);
            var req = new WarehousesCountGetRequest();

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

            WarehouseProxyUtils.ThrowOnHttpResponseError(resp);
            return(long.Parse(await resp.RawContent.ReadAsStringAsync()));
        }
        public async Task <IWarehouseState> GetHistoryStateAsync(string warehouseId, long version)
        {
            var idObj         = warehouseId;
            var uriParameters = new WarehouseHistoryStateUriParameters();

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

            var req  = new WarehouseHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.WarehouseHistoryState.Get(req);

            WarehouseProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToWarehouseState());
        }
        public async Task <IWarehouseEvent> GetStateEventAsync(string warehouseId, long version)
        {
            var idObj         = warehouseId;
            var uriParameters = new WarehouseStateEventUriParameters();

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

            var req  = new WarehouseStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.WarehouseStateEvent.Get(req);

            WarehouseProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IWarehouseState> GetAsync(string warehouseId)
        {
            IWarehouseState state         = null;
            var             idObj         = warehouseId;
            var             uriParameters = new WarehouseUriParameters();

            uriParameters.Id = idObj;

            var req = new WarehouseGetRequest(uriParameters);

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

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

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

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

            WarehouseProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToWarehouseState());
            return(states);
        }
        public async Task WhenAsync(DeleteWarehouseDto c)
        {
            var idObj         = (c as IDeleteWarehouse).WarehouseId;
            var uriParameters = new WarehouseUriParameters();

            uriParameters.Id = idObj;

            var q = new WarehouseDeleteQuery();

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

            var req = new WarehouseDeleteRequest(uriParameters);

            req.Query = q;

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

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

            q.Filter = WarehouseProxyUtils.GetFilterQueryValueString(filter);
            var req = new WarehousesCountGetRequest();

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

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