コード例 #1
0
        public Task AddToBasket(AvailableCoffeeKind kind, CoffeePack pack, int count)
        {
            var torrefactoId = kind.GetActualTorrefactoId(pack);
            var data         = new NameValueCollection
            {
                { "action", "ADD2BASKET" },
                { "ajax_buy", "1" },
                { "typ", "0" },
                { "id_0", torrefactoId },
                { "quantity", count.ToString(CultureInfo.InvariantCulture) },
                { "HOW_0", "Не молоть" },
                { "package", "Зип-лок" }
            };

            return(_client.UploadValuesTaskAsync(getFullUrl("/ajax.php"), data));
        }
コード例 #2
0
        private static IEnumerable <CoffeePack.Builder> tryParsePacksAndPrices(HtmlNode priceHolder)
        {
            if (priceHolder == null)
            {
                return(null);
            }

            return(priceHolder
                   .ChildNodes.Single(n => hasClass(n, "price-block"))
                   .ChildNodes.Where(n => hasClass(n, "row"))
                   .Select(n => CoffeePack.Create(

                               weight: int.Parse(
                                   n.ChildNodes.Single(_ => hasClass(_, "weight")).InnerText.Replace(" г", "")),

                               price: int.Parse(
                                   n.ChildNodes.Single(_ => hasClass(_, "price")).InnerText.Replace("&nbsp;&#8399;", ""))
                               )));
        }