Ejemplo n.º 1
0
        private async Task <IEnumerable <ProductDTO> > GetByProviderAsync(string provider, string query)
        {
            var products = Enumerable.Empty <ProductDTO>();

            switch (provider.ToLower())
            {
            case "amazon":
                products = await AmazonWebScraper.GetProductsByQueryAsync(query);

                return(products);

            case "bestbuy":
                products = await BestBuyWebScraper.GetProductsByQueryAsync(query);

                return(products);

            case "costco":
                products = await CostcoWebScraper.GetProductsByQueryAsync(query);

                return(products);

            case "ebay":
                products = await EbayWebScraper.GetProductsByQueryAsync(query);

                return(products);

            case "sams":
                products = await SamsWebApiScraper.GetProductsByQueryAsync(query);

                return(products);

            case "target":
                products = await TargetWebApiScraper.GetProductsByQueryAsync(query);

                return(products);

            case "walmart":
                products = await WalmartWebScraper.GetProductsByQueryAsync(query);

                return(products);

            default:
                return(products);
            }
        }
Ejemplo n.º 2
0
        public static async Task <IEnumerable <ProductDTO> > GetAllProductsFromScrapersAsync(string query)
        {
            var getAmazonProductsTask  = AmazonWebScraper.GetProductsByQueryAsync(query);
            var getBestBuyProductsTask = BestBuyWebScraper.GetProductsByQueryAsync(query);
            var getCostcoProductsTask  = CostcoWebScraper.GetProductsByQueryAsync(query);
            var getEbayProductsTask    = EbayWebScraper.GetProductsByQueryAsync(query);
            var getSamsProductsTask    = SamsWebApiScraper.GetProductsByQueryAsync(query);
            var getTargetProductsTask  = TargetWebApiScraper.GetProductsByQueryAsync(query);
            var getWalmartProductsTask = WalmartWebScraper.GetProductsByQueryAsync(query);
            var products = new List <ProductDTO>();

            products.AddRange(await getAmazonProductsTask);
            products.AddRange(await getBestBuyProductsTask);
            products.AddRange(await getCostcoProductsTask);
            products.AddRange(await getEbayProductsTask);
            products.AddRange(await getSamsProductsTask);
            products.AddRange(await getTargetProductsTask);
            products.AddRange(await getWalmartProductsTask);

            return(products);
        }