public async Task <IEnumerable <object> > GetMasjidsNearestToLocation(double Latitude, double Longitude, int Radius) { List <Masjid> Markers = await _taqweemService.MasjidGetByCoordinateRangeAsync(Latitude, Longitude).ConfigureAwait(false); List <Masjid> Nearest = new List <Masjid>(); foreach (var Item in Markers) { var d = cCalculations.DistanceTo(Latitude, Longitude, Item.Latitude, Item.Longitude); if (d < Radius) { Item.Distance = Math.Round(d, 2); Nearest.Add(Item); } } return(Nearest .OrderBy(s => s.Distance) .Select(d => new MasjidDTOLight { Id = d.Id, Name = d.Name, Town = d.Town, Country = d.Country }) .Take(20) .ToList()); }
public List <Masjid> NearestMasjids(double Latitude, double Longitude, int Radius) { List <Masjid> Markers = _taqweemService.MasjidGetByCoordinateRangeAsync(Latitude, Longitude).Result; List <Masjid> Nearest = new List <Masjid>(); foreach (var Item in Markers) { var d = cCalculations.DistanceTo(Latitude, Longitude, Item.Latitude, Item.Longitude); if (d < Radius) { Item.Distance = Math.Round(d, 2); Nearest.Add(Item); } } return(Nearest.OrderBy(s => s.Distance).ToList()); }