public List <ClosestGooglePlaceResponse> Get() { var closestPlaces = new List <ClosestGooglePlaceResponse>(); if (!string.IsNullOrEmpty(PostCode)) { var postcodeData = GetResponseString($"http://api.postcodes.io/postcodes/{PostCode}"); postcodeData.Wait(); var postcode = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(postcodeData.Result); Latitude = float.Parse(postcode.result.latitude.ToString()); Longitude = float.Parse(postcode.result.longitude.ToString()); } var types = Types?.Aggregate("", (current, type) => current + (type + "|")) ?? ""; var names = Names?.Aggregate("", (current, type) => current + (type + " ")) ?? ""; string url = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={Latitude},{Longitude}&radius=500&types={types}&name={names}&keyword={Keyword}&key={APIKey}"; if (Opennow) { url += "opennow"; } var googlePlacesResponse = GetResponseString(url); googlePlacesResponse.Wait(); var googlePlaces = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(googlePlacesResponse.Result); if (googlePlaces.results.Count <= 0) { return(closestPlaces); } foreach (var googlePlace in googlePlaces.results) { var closestPlace = new ClosestGooglePlaceResponse { Name = googlePlace.name?.ToString(), Latitude = float.Parse(googlePlace.geometry.location.lat.ToString()), Longitude = float.Parse(googlePlace.geometry.location.lng.ToString()), Icon = googlePlace.icon?.ToString(), Vicinity = googlePlace.vicinity?.ToString(), Rating = googlePlace.rating?.ToString(), }; closestPlace.SetDistanceFrom(Latitude, Longitude); closestPlaces.Add(closestPlace); } return(closestPlaces); }
public override int GetHashCode() { return(Module.MetadataToken * 1000000349 + Names.Aggregate(Types.Aggregate(0, (current, t) => current * 314159265 + t.GetHashCode()), (current, t) => current * 271828459 + t.GetHashCode())); }