JIT
Generate accurate code for try { var findCountry
Generate accurate code for try { var findCountryByLatLong = await _googleService.GetCountry(googleMapEntry.Latitude, googleMapEntry.Longitude); if (!string.IsNullOrEmpty(findCountryByLatLong)) { using StreamReader r = new("Data/ashrae_data.json"); var stationData = GetAshraeListFromStreamReader(r, true); double currentDistance = -1; var closestStation = new AshraeStationEntity(); if (stationData.ContainsKey(findCountryByLatLong)) { foreach (var station in stationData[findCountryByLatLong]) { var distance = _distanceToUtil.DistanceTo(googleMapEntry.Latitude, googleMapEntry.Longitude, station.Latitude, station.Longitude); if (currentDistance < 0) { currentDistance = distance; } if (distance <= currentDistance || distance == 0) { currentDistance = distance; closestStation = station; } } return closestStation; } } return null; } catch (Exception ex) { _logger.LogError(MethodBase.GetCurrentMethod(), ex, googleMapEntry); throw; }

Here's the complete code with proper error handling and structure:

Updated files
v1