Ejemplo n.º 1
0
        public IList <Category> GetCategories()
        {
            ProductRequest request = new ProductRequest();

            request.RequestId   = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag   = ClientTag;

            request.LoadOptions = new string[] { "Categories" };

            ProductResponse response = ActionServiceClient.GetProducts(request);

            if (request.RequestId != response.CorrelationId)
            {
                throw new ApplicationException("GetCategories: RequestId and CorrelationId do not match.");
            }

            return(response.Categories);
        }
Ejemplo n.º 2
0
        public Product GetProduct(int productId)
        {
            ProductRequest request = new ProductRequest();

            request.RequestId   = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag   = ClientTag;

            request.LoadOptions = new string[] { "Product" };
            request.Criteria    = new ProductCriteria {
                ProductId = productId
            };

            ProductResponse response = ActionServiceClient.GetProducts(request);

            if (request.RequestId != response.CorrelationId)
            {
                throw new ApplicationException("GetProductsByCategory: RequestId and CorrelationId do not match.");
            }

            return(response.Product);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Searches for products.
        /// </summary>
        /// <param name="productName">Product name.</param>
        /// <param name="priceRangeId">Price range identifier.</param>
        /// <param name="sortExpression">Sort order in which products are returned.</param>
        /// <returns>List of products that meet the search criteria.</returns>
        public IList <Product> SearchProducts(string productName, int priceRangeId, string sortExpression)
        {
            ProductRequest request = new ProductRequest();

            request.RequestId   = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag   = ClientTag;

            request.LoadOptions = new string[] { "Products", "Search" };

            double priceFrom = -1;
            double priceThru = -1;

            if (priceRangeId > 0)
            {
                PriceRangeItem pri = PriceRange.List[priceRangeId];
                priceFrom = pri.RangeFrom;
                priceThru = pri.RangeThru;
            }

            request.Criteria = new ProductCriteria
            {
                ProductName    = productName,
                PriceFrom      = priceFrom,
                PriceThru      = priceThru,
                SortExpression = sortExpression
            };

            ProductResponse response = ActionServiceClient.GetProducts(request);

            if (request.RequestId != response.CorrelationId)
            {
                throw new ApplicationException("SearchProducts: Request and CorrelationId do not match.");
            }

            return(response.Products);
        }
Ejemplo n.º 4
0
        public IList <Product> GetProducts(int categoryId, string sortExpression)
        {
            ProductRequest request = new ProductRequest();

            request.RequestId   = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag   = ClientTag;

            request.LoadOptions = new string[] { "Products" };
            request.Criteria    = new ProductCriteria
            {
                CategoryId     = categoryId,
                SortExpression = sortExpression
            };

            ProductResponse response = ActionServiceClient.GetProducts(request);

            if (request.RequestId != response.CorrelationId)
            {
                throw new ApplicationException("GetProductsByCategory: RequestId and CorrelationId do not match.");
            }

            return(response.Products);
        }