Пример #1
0
        public ParkReview GetParkReview(SeattleParkInfo park)
        {
            var findPark = YelpClient.SearchBusinessesAllAsync(park.Name, park.Latitude, park.Longitude).Result;

            //BusinessResponse results = YelpClient.GetBusinessAsync(findPark.Businesses.FirstOrDefault().Name).Result;

            return(new ParkReview(findPark.Businesses.FirstOrDefault()));
        }
Пример #2
0
        private static List <SeattleParkInfo> GetSeattleParksCachedData()
        {
            var parks           = JsonConvert.DeserializeObject <SeattleParksCachedData>(File.ReadAllText(@".\CachedData\SeattleParks.json"));
            var seattleParkList = new List <SeattleParkInfo>();

            var nameOrdinal      = -1;
            var longitudeOrdinal = -1;
            var latitudeOrdinal  = -1;

            var columnPositionCounter = 0;

            foreach (var column in parks.meta.view.columns)
            {
                if (column.name.Equals("name", StringComparison.InvariantCultureIgnoreCase))
                {
                    nameOrdinal = columnPositionCounter;
                }

                if (column.name.Equals("xpos", StringComparison.InvariantCultureIgnoreCase))
                {
                    longitudeOrdinal = columnPositionCounter;
                }

                if (column.name.Equals("ypos", StringComparison.InvariantCultureIgnoreCase))
                {
                    latitudeOrdinal = columnPositionCounter;
                }

                columnPositionCounter++;
            }

            foreach (var park in parks.data)
            {
                if (seattleParkList?.Where(p => string.IsNullOrWhiteSpace(p.Name) == false && p.Name.Equals(park[nameOrdinal])).Any() == false)
                {
                    var scrappedData = SeattleParkScrappedDataList
                                       .FirstOrDefault(p => string.IsNullOrWhiteSpace(p.Title) == false &&
                                                       p.Title.Equals(park[nameOrdinal].ToString(), StringComparison.InvariantCultureIgnoreCase));

                    var sp = new SeattleParkInfo(park[nameOrdinal],
                                                 park[longitudeOrdinal],
                                                 park[latitudeOrdinal],
                                                 scrappedData);

                    seattleParkList.Add(sp);
                }
            }

            return(seattleParkList);
        }