private static void createBrowsePrices()
        {
            foreach (var departDate in _departDates)
            {
                var perDatePrices = new List<WebsiteAirlineBrowsePrice>();

                foreach (var website in _websites)
                {
                    foreach (var airlineId in website.AirlinesIds)
                    {
                        var browsePrice = new WebsiteAirlineBrowsePrice
                                          {
                                          	Website = website.Id,
                                          	Airline = airlineId,
                                          	FromAirport = "EDI",
                                          	ToAirport = "LHR",
                                          	DepartDate = departDate,
                                          	MinPrice = GenerateRandomPrice()
                                          };

                        perDatePrices.Add(browsePrice);
                    }
                }

                var minPricePerDate = perDatePrices.Min(bp => bp.MinPrice);

                foreach (var browsePrice in perDatePrices)
                {
                    browsePrice.PriceDelta = browsePrice.MinPrice - minPricePerDate;
                    storeBrowsePrice(browsePrice);
                }
            }
        }
        private static void updatePrice(string websiteId, string airlineId, int day, decimal price)
        {
            var date = new DateTime(2013, 1, day);

            var browsePrices = _client.GetView<WebsiteAirlineBrowsePrice>("test", "ByRouteDate", true)
                .StartKey(new object[] { "EDI", "LHR", 2013, 1, day })
                .EndKey(new object[] { "EDI", "LHR", 2013, 1, day + 1})
                .ToList();

            Console.WriteLine();

            Console.WriteLine("Before:");
            outputBrowsePrices(browsePrices, date);
            outputStats(date);

            var selectedBrowsePrice = browsePrices.FirstOrDefault(d => d.Website == websiteId && d.Airline == airlineId);
            if (selectedBrowsePrice != null)
            {
                selectedBrowsePrice.MinPrice = price;
            }
            else
            {
                selectedBrowsePrice = new WebsiteAirlineBrowsePrice
                      {
                      	Website = websiteId,
                      	Airline = airlineId,
                      	FromAirport = "EDI",
                      	ToAirport = "LHR",
                        DepartDate = date,
                      	MinPrice = GenerateRandomPrice()
                      };
                browsePrices.Add(selectedBrowsePrice);
            }

            Console.WriteLine("Updated Price: {0}", selectedBrowsePrice.MinPrice.ToString("C"));
            Console.WriteLine();

            var minOverallPrice = browsePrices.Min(d => d.MinPrice);
            foreach (var browsePrice in browsePrices)
            {
                browsePrice.PriceDelta = browsePrice.MinPrice - minOverallPrice;
                storeBrowsePrice(browsePrice);
            }

            Thread.Sleep(200);

            Console.WriteLine("After:");
            outputBrowsePrices(browsePrices, date);
            outputStats(date);
        }
        private static void storeBrowsePrice(WebsiteAirlineBrowsePrice browsePrice)
        {
            var result =
                _client.Store(
                    StoreMode.Set, browsePrice.Key,
                    JsonConvert.SerializeObject(browsePrice, new JsonSerializerSettings {DateFormatHandling = DateFormatHandling.IsoDateFormat}));

            if (!result)
                Console.WriteLine("Failed to store: {0}", browsePrice.Key);
        }