Ejemplo n.º 1
0
        /// <summary>
        /// by BestBuySKU
        /// </summary>
        /// <param name="product">BestBuySKU</param>
        public static void Do(Product product)
        {
            if (string.IsNullOrEmpty(product.BBYSKU))
                return;

            Remix.Server server = new Remix.Server("", "");
            Remix.Reviews remixReviews = server.GetReview(product.BBYSKU, 1);
            if (remixReviews.Count > 0)
            {
                foreach (var remixReview in remixReviews)
                {
                    Review review = new Review()
                                        {
                                            Title = remixReview.Title,
                                            Content = remixReview.Comment,
                                            Author = remixReview.Reviewer.Name,
                                            Source = "Best Buy",
                                            SourceUrl = ""
                                        };
                    DateTime.TryParse(remixReview.SubmissionTime, out review.PubTime);
                    decimal.TryParse(remixReview.Rating, out review.Rating);

                    product.Reviews.Add(review);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// by upc or sku
        /// </summary>
        /// <param name="product">must contain upc or sku</param>
        public static void Do(Product product)
        {
            Remix.Server server = new Remix.Server("", "");
            Remix.Products remixProducts = null;
            if (!string.IsNullOrEmpty(product.UPC))
                remixProducts = server.GetProduct(product.UPC);
            else if (!string.IsNullOrEmpty(product.BBYSKU))
                remixProducts = server.GetProduct(product.BBYSKU, false);

            if (remixProducts != null && remixProducts.Count > 0)
            {
                Remix.Product p = remixProducts[0];
                product.BBYSKU = p.Sku;
                product.UPC = p.UPC;
                product.Name = p.Name;
                product.BBYCategoryPath = p.CategoryPath.ToArray();
                product.LargeImageUrl = string.IsNullOrEmpty(p.LargeFrontImageUrl) ?
                    p.LargeImageUrl : p.LargeFrontImageUrl;
                product.LargeImageUrl = string.IsNullOrEmpty(product.LargeImageUrl) ?
                    p.ImageUrl : product.LargeImageUrl;
                product.ThumbnailImageUrl = string.IsNullOrEmpty(p.ImageUrl) ?
                    p.ThumbnailimageUrl : p.ImageUrl;
                product.BBYUrl = p.BBYUrl;
                product.BBYCJAffiliateUrl = p.CJAffiliateUrl;
                product.BBYClassId = p.ClassId;
                product.BBYClassName = p.Class;
                product.BBYSubClassId = p.SubclassId;
                product.BBYSubClassName = p.Subclass;

                int.TryParse(p.CustomerReviewCount, out product.BBYCustomerReviewCount);
                decimal.TryParse(p.CustomerReviewAverage, out product.BBYCustomerReviewAverage);

                product.Desc = p.LongDescription;
                product.DescShort = p.ShortDescription;
                decimal.TryParse(p.SalePrice, out product.BBYSalePrice);
                decimal.TryParse(p.RegularPrice, out product.BBYRegularPrice);

                int.TryParse(p.SalesRankLongTerm, out product.BBYSalesRankLongTerm);
                int.TryParse(p.SalesRankMediumTerm, out product.BBYSalesRankMediumTerm);
                int.TryParse(p.SalesRankShortTerm, out product.BBYSalesRankShortTerm);

                if (p.RelatedProducts != null)
                {
                    foreach (var sku in p.RelatedProducts)
                    {
                        product.SimilarProducts.Add(new Product() { BBYSKU = sku });
                    }
                }

                if (p.Accessories != null)
                {
                    foreach (var sku in p.Accessories)
                    {
                        product.Accessories.Add(new Product() { BBYSKU = sku });
                    }
                }
            }
        }
        public static void Do(Products products, string keyword)
        {
            products.Type = AggregationType.BySearch;

            string[] keywords = keyword.Split(new char[] {',', ';', ' '});

            Remix.Server server = new Remix.Server("", "");
            Remix.Products remixProducts = server.GetProductByKeywords(keywords, products.CurrentPage);

            List<string> relatedSkuList = new List<string>();
            if (remixProducts != null && remixProducts.Count > 0)
            {
                int.TryParse(remixProducts.TotalPages, out products.TotalPages);
                int.TryParse(remixProducts.Total, out products.Total);
                int.TryParse(remixProducts.To, out products.To);
                int.TryParse(remixProducts.From, out products.From);
                int.TryParse(remixProducts.CurrentPage, out products.CurrentPage);

                foreach (var remixProduct in remixProducts)
                {
                    Product product = new Product();
                    product.BBYSKU = remixProduct.Sku;
                    product.UPC = remixProduct.UPC;
                    product.Name = remixProduct.Name;
                    product.BBYCategoryPath = remixProduct.CategoryPath.ToArray();
                    product.ThumbnailImageUrl = string.IsNullOrEmpty(remixProduct.ImageUrl) ?
                        remixProduct.ThumbnailimageUrl : remixProduct.ImageUrl;
                    product.LargeImageUrl = remixProduct.LargeImageUrl;
                    product.BBYUrl = remixProduct.BBYUrl;

                    product.BBYSubClassId = remixProduct.SubclassId;
                    product.BBYSubClassName = remixProduct.Subclass;

                    product.DescShort = remixProduct.ShortDescription;
                    decimal.TryParse(remixProduct.SalePrice, out product.BBYSalePrice);

                    if (remixProduct.RelatedProducts != null)
                    {
                        foreach (var sku in remixProduct.RelatedProducts)
                        {
                            product.SimilarProducts.Add(new Product() { BBYSKU = sku });
                            relatedSkuList.Add(sku);
                        }
                    }

                    products.Add(product);
                }
            }

            //
        }
Ejemplo n.º 4
0
        public static Product[] DoBySkus(string[] skus)
        {
            if (skus == null || skus.Length == 0)
                return new Product[] { };

            // process 1 page once.
            List<string> skuList = new List<string>(skus);

            Remix.Server server = new Remix.Server("", "");
            List<Product> products = new List<Product>();
            for (int i = 0; i < skuList.Count; i += BBY_PAGE_SIZE)
            {
                Remix.Products remixProducts = server.GetProductBySkus(skuList.GetRange(i,
                    skuList.Count - i > BBY_PAGE_SIZE ? BBY_PAGE_SIZE : skuList.Count - i).ToArray());
                products.AddRange(Fill(remixProducts));
            }

            return products.ToArray();
        }