Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            var hashCode = 1007649997;

            hashCode = hashCode * -1521134295 + DeliveryId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DeliveryDate);

            hashCode = hashCode * -1521134295 + DeliveryPrice.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DeliveryAddress);

            hashCode = hashCode * -1521134295 + CardNumber.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Description);

            return(hashCode);
        }
Ejemplo n.º 2
0
        public static DeliveryPrice ParseDeliveryPrices(string mode, string html)
        {
            var document = new HtmlParser().ParseDocument(html);

            var content = document.QuerySelector("div.ctrlcontent");

            var error = document.QuerySelectorAll(".info.error").ToList();

            if (error.Count > 0)
            {
                throw new ParseException("Não foi possível calcular o preço de entrega.", error.Select(x => x.Text()).ToArray());
            }



            var tableRows = content.QuerySelectorAll("table.comparaResult tr.destaque td").ToList();



            Regex rgx = new Regex(@"\d+");


            var termText  = tableRows[0].Text();
            var priceText = tableRows[1].Text();

            var match = rgx.Match(termText);


            decimal price;


            decimal.TryParse(priceText, NumberStyles.Currency, new CultureInfo("pt-BR"), out price);


            var deliveryPrice = new DeliveryPrice();

            deliveryPrice.Mode  = mode;
            deliveryPrice.Days  = match.Success ? int.Parse(match.Value) : -1;
            deliveryPrice.Price = price;


            return(deliveryPrice);
        }