Esempio n. 1
0
        private string SearchForPizza(string pizzaName)
        {
            pizzaName = pizzaName.ToLower();

            var url     = $"{ProviderUrlConst}cs/vyhledavani?search_query={pizzaName}";
            var content = httpClient.GetString(url);

            DebugContent.WriteToHtmlFile(content);

            var document = new HtmlDocument();

            document.LoadHtml(content);
            var pizzas   = GetPizzas(document.DocumentNode).ToList();
            var searched = pizzas.FirstOrDefault(p => p.Name == pizzaName);

            if (searched == null)
            {
                throw new PizzaProviderException($"Failed to find order button for pizza {pizzaName}. It is possible that the pizzeria is closed at the moment or that there are no pizzas with name {pizzaName}.");
            }

            return(searched.OrderUrl);
        }