Exemple #1
0
        public async Task <IEnumerable <IProductState> > GetAsync(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue, IList <string> fields = null)
        {
            IEnumerable <IProductState> states = null;
            var q = new ProductsGetQuery();

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

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

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToProductState());
            return(states);
        }
Exemple #2
0
        public async virtual Task <long> GetCountAsync(ICriterion filter)
        {
            var q = new ProductsCountGetQuery();

            q.Filter = ProductProxyUtils.GetFilterQueryValueString(filter);
            var req = new ProductsCountGetRequest();

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

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