Exemple #1
0
        public async Task WhenAsync(MergePatchProductDto c)
        {
            var idObj         = (c as IMergePatchProduct).ProductId;
            var uriParameters = new ProductUriParameters();

            uriParameters.Id = idObj;

            var req  = new ProductPatchRequest(uriParameters, (MergePatchProductDto)c);
            var resp = await _ramlClient.Product.Patch(req);

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
        }
Exemple #2
0
        public async virtual Task <IGoodIdentificationState> GetGoodIdentificationAsync(string productId, string goodIdentificationTypeId)
        {
            var uriParameters = new GoodIdentificationUriParameters();

            uriParameters.ProductId = productId;
            uriParameters.GoodIdentificationTypeId = goodIdentificationTypeId;

            var req  = new GoodIdentificationGetRequest(uriParameters);
            var resp = await _ramlClient.GoodIdentification.Get(req);

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToGoodIdentificationState());
        }
Exemple #3
0
        public async Task <IProductState> GetHistoryStateAsync(string productId, long version)
        {
            var idObj         = productId;
            var uriParameters = new ProductHistoryStateUriParameters();

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

            var req  = new ProductHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.ProductHistoryState.Get(req);

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToProductState());
        }
Exemple #4
0
        public async Task <IProductEvent> GetStateEventAsync(string productId, long version)
        {
            var idObj         = productId;
            var uriParameters = new ProductStateEventUriParameters();

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

            var req  = new ProductStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.ProductStateEvent.Get(req);

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
Exemple #5
0
        public async Task <IProductState> GetAsync(string productId)
        {
            IProductState state         = null;
            var           idObj         = productId;
            var           uriParameters = new ProductUriParameters();

            uriParameters.Id = idObj;

            var req = new ProductGetRequest(uriParameters);

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

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToProductState();
            return(state);
        }
Exemple #6
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 #7
0
        public async Task WhenAsync(DeleteProductDto c)
        {
            var idObj         = (c as IDeleteProduct).ProductId;
            var uriParameters = new ProductUriParameters();

            uriParameters.Id = idObj;

            var q = new ProductDeleteQuery();

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

            var req = new ProductDeleteRequest(uriParameters);

            req.Query = q;

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

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
        }
Exemple #8
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));
        }