Beispiel #1
0
        public void LoadRoot(GeneratorContext context, string query)
        {
            var locations           = new List <Miejsce>();
            LocationRootObject root = LocationProcessor.LoadLocation(query);

            foreach (var i in root.results)
            {
                locations.Add(new Miejsce()
                {
                    MiejsceId = i.place_id, Lat = i.geometry.location.lat, Lng = i.geometry.location.lng, Name = i.name, visitCount = 0, type = query
                });
            }
            locations.ForEach(g => context.Locations.AddOrUpdate(g));
            context.SaveChanges();
        }
        public void LoadRoot(GeneratorContext context, string query, string town, int radius)
        {
            string nextPageToken = null;
            var    locations     = new List <Location>();

            do
            {
                LocationRootObject root = LocationProcessor.LoadLocation(query, nextPageToken, town, radius);
                foreach (var i in root.results)
                {
                    locations.Add(new Location()
                    {
                        LocationId = i.place_id, Lat = i.geometry.location.lat,
                        Lng        = i.geometry.location.lng, Name = i.name, visitCount = 0, type = query
                    });
                }
                nextPageToken = root.next_page_token;
            }while (nextPageToken != null);
            locations.ForEach(g => context.Locations.AddOrUpdate(g));
            context.SaveChanges();
        }