public RouteInformation FindNearestWay(RouteInformation routeInformation) { PointLatLng userLoc = new PointLatLng(routeInformation.startCoordinatesLat, routeInformation.startCoordinatesLng); PointLatLng nearestPoint = new PointLatLng(); string excursionRoute = String.Empty; double maxDistance = Double.MaxValue; int IdVisitedExcursionRout = 0; using (DbContextTourists dbContext = new DbContextTourists()) { List <Route> routes = dbContext.Routes.Where(a => a.CityID == routeInformation.IdCurrentCity).ToList(); foreach (var item in routes) { List <PointLatLng> pointsStartedRoute = Helper.StringToListLatLng(item.CoordinatesStartingPointsRouteOGC); foreach (var pointSR in pointsStartedRoute) { double distance = Map.GetRouteDistance(userLoc, pointSR); if (distance < maxDistance) { maxDistance = distance; nearestPoint = pointSR; excursionRoute = Helper.DeleteLetterFromString(item.CoordinatesOGC); IdVisitedExcursionRout = item.ID; } } } } return(PrepareRouteInformation(routeInformation, userLoc, nearestPoint, IdVisitedExcursionRout, excursionRoute)); }
public List <string> GetExcursionRoutes(int idCurrentCity) { List <string> excursionRoutes = new List <string>(); using (DbContextTourists dbContext = new DbContextTourists()) { var temp = dbContext.Routes.Where(t => t.CityID == idCurrentCity).ToList(); foreach (var item in temp) { excursionRoutes.Add(Helper.DeleteLetterFromString(item.CoordinatesOGC)); } } return(excursionRoutes); }
public List <Attraction> GetAttractions(int idCurrentCity) { List <Attraction> listAttractions = new List <Attraction>(); using (DbContextTourists dbContext = new DbContextTourists()) { var temp = dbContext.Attractions.Where(t => t.CityID == idCurrentCity).ToList(); foreach (var item in temp) { listAttractions.Add(new Attraction(item.Name, item.Description, Helper.DeleteLetterFromString(item.CoordinateOGC))); } } return(listAttractions); }
public City GetIdCurrentCity(string selectedCity) { City cityInformation = new City(); using (DbContextTourists dbContext = new DbContextTourists()) { bool isCityFinded = dbContext.Cities.Any(u => u.Name == selectedCity); if (isCityFinded) { cityInformation.Id = dbContext.Cities.Where(t => t.Name == selectedCity).Select(t => t.Id).ToList()[0]; cityInformation.CoordinateOGC = Helper.DeleteLetterFromString(dbContext.Cities. Where(t => t.Id == cityInformation.Id). Select(t => t.CoordinateOGC).ToList()[0]); } else { cityInformation.Id = -1; } } return(cityInformation); }