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; }
public static RestaurantInspectionDto MakeRestaurantInspectionDto(JsonValue returnString) { var returnStringResults = returnString["result"]; var inspectionList = new List<RestaurantInspectionDto>(); var inspectionData = new RestaurantInspectionDto(); if (returnStringResults["total"] != 0) { var returnStringRecords = returnStringResults["records"]; foreach (JsonValue establishment in returnStringRecords) { var locationFound = new RestaurantInspectionDto() { EstablishmentId = establishment["EstablishmentId"], EstablishmentName = establishment["EstablishmentName"], Grade = establishment["Grade"], Score = establishment["Score"], InspectionDate = establishment["InspectionDate"] }; inspectionList.Add(locationFound); } inspectionData = inspectionList.OrderByDescending(i => i.InspectionDate).ToList().FirstOrDefault(); } return inspectionData; }