private static List<YelpListingDto> MakeYelpListingDto(JsonValue restaurantList)
        {
            var yelpListingDtoList = new List<YelpListingDto>();

            var businesses = restaurantList["businesses"];

            foreach (JsonValue business in businesses)
            {
                var location = business["location"];
                var address = location["address"];
                var coordinates = location["coordinate"];

                var listing = new YelpListingDto()
                {
                    Id = business["id"],
                    Name = business["name"],
                    Address = address[0],
                    City = location["city"],
                    Latitude = coordinates["latitude"],
                    Longitude = coordinates["longitude"],
                    LocationClosed = business["is_closed"],
                    MobileUrl = business["mobile_url"],
                    Rating = business["rating"],
                    NumberReviews = business["review_count"],
                    RatingImage = business["rating_img_url_large"]
                };

                yelpListingDtoList.Add(listing);
            }

            return yelpListingDtoList;
        }
        public static async Task<RestaurantInspectionDto> MatchYelpAndEstablishment(YelpListingDto restaurant)
        {
            var establishmentId = default(int);
            var restaurantLatitude = TruncateCoords(restaurant.Latitude);
            var restaurantLongitude = TruncateCoords(restaurant.Longitude);

            var restaurantMatches = await MatchRestaurant(restaurant);

            foreach (var match in restaurantMatches)
            {
                var matchLatitude = TruncateCoords(match.Latitude);
                var matchLongitude = TruncateCoords(match.Longitude);

                if (matchLatitude == restaurantLatitude || matchLongitude == restaurantLongitude)
                {
                    if (match.Name.Substring(0,1).ToUpper() == restaurant.Name.Substring(0,1).ToUpper())
                    {
                        establishmentId = match.EstablishmentId;
                    }
                }
            }

            var inspectionData = new RestaurantInspectionDto();

            if (establishmentId != default(int))
            {
                inspectionData = await GetInspectionData(establishmentId);
            }

            return inspectionData;
        }
        private static async Task<List<LocationMatchDto>> MatchRestaurant(YelpListingDto restaurant)
        {
            var streetNumber = TruncateAddress(restaurant);
            var findEstablishment =
                @"http://data.louisvilleky.gov/api/action/datastore/search.json?resource_id=406f03bb-a022-4b6c-9460-8f0826b91a2b&filters[PermiseStreetNo]=" +
                streetNumber;

            var returnString = await HttpRequestSetup.MakeRequest(findEstablishment);
            return MakeLocationMatchDto(returnString);
        }
 private static string TruncateAddress(YelpListingDto restaurant)
 {
     var streetNumberPos = restaurant.Address.IndexOf(" ", StringComparison.Ordinal);
     return restaurant.Address.Substring(0,streetNumberPos);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.RatingsViolationsComparison);

            var restaurantToParse = Intent.Extras.GetString("restaurant") ?? "blank";
            var restaurant = new YelpListingDto();

            var inspectionToParse = Intent.Extras.GetString("inspectionData") ?? "blank";

            if (restaurantToParse != "blank")
            {
                restaurant = JsonConvert.DeserializeObject<YelpListingDto>(restaurantToParse);
            }

            FindViewById<TextView>(Resource.Id.comparisonGrade).Text = "No inspection data found.";

            if (inspectionToParse != "blank")
            {
                var inspection = JsonConvert.DeserializeObject<RestaurantInspectionDto>(inspectionToParse);

                if (inspection.EstablishmentId != 0)
                {
                    FindViewById<TextView>(Resource.Id.comparisonScore).Text = $"Overall Score: {inspection.Score}";
                    FindViewById<TextView>(Resource.Id.comparisonGrade).Text = $"Inspection Grade: {inspection.Grade}";
                    FindViewById<TextView>(Resource.Id.comparisonInspectedOn).Text = "Inspected On";
                    FindViewById<TextView>(Resource.Id.comparisonInspectionDate).Text =
                        FormatDate(inspection.InspectionDate);
                }
            }

            FindViewById<TextView>(Resource.Id.comparisonRestaurantName).Text = restaurant.Name;
            FindViewById<TextView>(Resource.Id.comparisonRestaurantAddress).Text = restaurant.Address;

            FindViewById<ImageView>(Resource.Id.comparisonYelpStars).SetImageBitmap(BitmapDownloader.GetRatingStars(restaurant.RatingImage));
            FindViewById<TextView>(Resource.Id.comparisonNumberStars).Text = $"{restaurant.Rating} Stars";
            FindViewById<TextView>(Resource.Id.comparisonNumberReviews).Text = $"{restaurant.NumberReviews} Ratings";

            var readReviewsButton = FindViewById<Button>(Resource.Id.readReviewsButton);
            var startOverButton = FindViewById<Button>(Resource.Id.startOverButton);
            var returnToListButton = FindViewById<ImageButton>(Resource.Id.returnToListButton);

            readReviewsButton.Click += (sender, e) =>
            {
                var uri = Android.Net.Uri.Parse(restaurant.MobileUrl);

                var intent = new Intent(Intent.ActionView, uri);

                StartActivity(intent);
            };

            startOverButton.Click += (sender, e) =>
            {
                StartActivity(typeof(MainActivity));
            };

            returnToListButton.Click += (sender, e) =>
            {
                OnBackPressed();
            };
        }