public IActionResult GetLocations(string auto, string radius) { var RouteIdIntNull = HttpContext.Session.GetInt32(sessionRouteId); var RouteId = RouteIdIntNull.GetValueOrDefault(); var locationType = "W"; Debug.WriteLine(radius); int radiusInt = 0; if (radius == null) { radiusInt = 16000; } else { radiusInt = Int32.Parse(radius); } Debug.WriteLine(radiusInt); var thisPlace = db.Locations.FirstOrDefault(p => p.RouteId == RouteId && (p.LocationType == "OD" || p.LocationType == "O")); var originLatitiude = thisPlace.Latitude; var originLongitude = thisPlace.Longitude; ViewBag.originLat = originLatitiude; ViewBag.originLng = originLongitude; var allLocations = new List <Location>(); if (radiusInt > 40000) { var allLocationsYelp = YelpPlace.GetLocationsExtend(auto, originLatitiude, originLongitude); var allLocationsGoogle = GoogleAuto.GetGoogleAddress(auto, originLatitiude, originLongitude, radiusInt); allLocations = allLocationsYelp; allLocations.AddRange(allLocationsGoogle); } else { var allLocationsYelp = YelpPlace.GetLocations(auto, originLatitiude, originLongitude, radiusInt); var allLocationsGoogle = GoogleAuto.GetGoogleAddress(auto, originLatitiude, originLongitude, radiusInt); allLocations = allLocationsYelp; allLocations.AddRange(allLocationsGoogle); } foreach (Location place in allLocations) { place.LocationType = locationType; } if (allLocations.Count > 0) { return(PartialView(allLocations)); } else { return(RedirectToAction("NoResult")); } }
public IActionResult GetAddressAuto(string term) { var RouteIdIntNull = HttpContext.Session.GetInt32(sessionRouteId); var RouteId = RouteIdIntNull.GetValueOrDefault(); var thisPlace = db.Locations.FirstOrDefault(p => p.RouteId == RouteId && (p.LocationType == "OD" || p.LocationType == "O")); var originLatitiude = thisPlace.Latitude; var originLongitude = thisPlace.Longitude; var allAuto = GoogleAuto.GetGoogleAddressAuto(term, originLatitiude, originLongitude); return(Json(allAuto)); }