Beispiel #1
0
        private LocationModel GetRadiusLocation(string latitude, string longitude, string radius)
        {
            try
            {
                LocationModel locationModel = new LocationModel();

                double radiusTemp  = Convert.ToDouble(radius);
                var    radiusMiles = ConvertDistance.ConvertKilometersToMiles(radiusTemp);


                SqlParameter StartingLatitude  = new SqlParameter("@latitude", latitude);
                SqlParameter StartingLongitude = new SqlParameter("@longitude", longitude);
                SqlParameter MaxDistance       = new SqlParameter("@radius", radiusMiles);

                var earthquakesGuids = earthquakeRepository.GetRadiusLocation(StartingLatitude, StartingLongitude, MaxDistance);
                IList <Earthquake> nearEarthquakes = new List <Earthquake>();

                foreach (Guid id in earthquakesGuids)
                {
                    var ea = earthquakeRepository.GetEarthquakeById(id);
                    if (ea != null)
                    {
                        nearEarthquakes.Add(ea);
                    }
                }
                locationModel.NearEarthquakes = nearEarthquakes;

                return(locationModel);
            }

            catch (Exception ex)
            {
                ExceptionUtility.Warn(ex, this.GetType());
                return(new LocationModel());
            }
        }
Beispiel #2
0
 private static void PrintServerDetails(Server server) => Console.WriteLine($"Hosted by {server.Sponsor} ({server.Name}/{server.Country}), " +
                                                                            $"distance: {(int)server.Distance / 1000}km " +
                                                                            $"({Math.Round(ConvertDistance.ConvertKilometersToMiles((int)server.Distance / 1000), 2)}mi), " +
                                                                            $"latency: {server.Latency}ms");