Ejemplo n.º 1
0
        protected void ImportClick(object sender, EventArgs e)
        {
            string[] isbnNumbers = LoadIsbnNumbers().ToArray();

            WipePriceDatabase();

            var collection = PriceHarvestRepository.MongoCollection();

            foreach (string isbnNumber in isbnNumbers)
            {
                var pricingService = new PricingService(new ConsoleLog());

                var pricingDetails = new PricingDetails()
                {
                    IsbnNumber = isbnNumber
                };

                foreach (Currency currency in pricingService.Currencies)
                {
                    var price = pricingService.FindPriceByIsbn(isbnNumber, currency);

                    PricingMapper.Map(isbnNumber, price, pricingDetails);
                }

                collection.Insert(pricingDetails);
            }
        }
Ejemplo n.º 2
0
        private static PricingCurrencyDetails GetCachedPrices(string isbn, string currency)
        {
            var result =
                PriceHarvestRepository.MongoCollection().FindOne(Query <PricingDetails> .EQ(a => a.IsbnNumber, isbn));

            if (result == null)
            {
                return(new PricingCurrencyDetails {
                    Value = Math.Round(Decimal.Parse(isbn) / 100000000000, 2), Currency = "&pound;"
                });
            }

            return(SelectCurrency(result, currency));
        }
Ejemplo n.º 3
0
 private void WipePriceDatabase()
 {
     PriceHarvestRepository.MongoCollection().Drop();
 }