static void Main(string[] args) { Console.WriteLine("Getting products from scrappers..."); var watch = new Stopwatch(); watch.Start(); var prods = ScrapersFacade.GetAllProductsFromScrapersAsync("tv 50 inch").Result; watch.Stop(); Console.WriteLine($"Retrieved {prods.Count()} from scrappers in {watch.ElapsedMilliseconds / 1000} seconds \n"); foreach (var prod in prods) { Console.WriteLine(prod.Title); if (prod.Image != null) { Console.WriteLine(prod.Image); } if (prod.Link != null) { Console.WriteLine(prod.Link); } if (prod.Price != null) { Console.WriteLine(prod.Price); } if (prod.Source != null) { Console.WriteLine(prod.Source); } Console.WriteLine(); } }
public async Task <IActionResult> Get(string provider, string query) { if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(query)) { return(BadRequest()); } QuisyDbRepository.AddLogAsync(SqlDbRepository.Entities.LogType.Information, "Query: " + query); var cacheKey = BuildCacheKey(provider, query); if (_cache.TryGetValue <IEnumerable <ProductDTO> >(cacheKey, out var products)) { return(Ok(products)); } if (provider.ToLower() == "all") { products = await ScrapersFacade.GetAllProductsFromScrapersAsync(query); } else { products = await GetByProviderAsync(provider, query); } if (products?.Any() == true) { _cache.Set(cacheKey, products); } return(Ok(products)); }