Example #1
0
        public void Run()
        {
            CoffeeEntities entities = new CoffeeEntities();
            DbSet<CoffeeShop> coffeeShops = entities.CoffeeShops;
            this.ClearDatabase(coffeeShops);
            entities.SaveChanges();

            SearchArea searchArea = new SearchArea
            {
                SouthwestCorner = new Coordinate
                {
                    latitude = (double)MinLatitude,
                    longitude = (double)MinLongitude,
                },
                NortheastCorner = new Coordinate
                {
                    latitude = (double)MaxLatitude,
                    longitude = (double)MaxLongitude,
                }
            };

            SearchResult result = this._coffeeSearcher.Search(searchArea).Result;
            if (result.Error != null)
            {
                throw new Exception(result.Error.Description);
            }
            else
            {
                foreach (CoffeeShop shop in result.Results)
                {
                    coffeeShops.Add(shop);
                }

                entities.SaveChanges();
            }
        }