コード例 #1
0
        public String getMessage(String radius, String filmName, String location)
        {
            String htmlList = "";

            IncomingRequestUI request = new IncomingRequestUI();
            request.radius = double.Parse ( radius.Substring(0, 1) );
            request.location = location;
            request.filmName = filmName;

            List<PresentedRestaurantUI> restList = newRestObject.getRestaurantsWithinRadius (request);

            foreach (PresentedRestaurantUI rest in restList)
            {
                String details = "<h5>Name: " + rest.name + "</h5>";
                if (rest.cuisine != null)
                    details += "<br>Cuisine: " + rest.cuisine;
                if (rest.fanciness != null)
                    details += "<br>Quality: " + rest.fanciness;
                if (rest.address != null)
                    details += "<br>Address: " + rest.address;
                if (rest.websiteURL != null)
                    details += "<br>Website: " + rest.websiteURL;

                htmlList += "<p>" + details + "</p>";
            }

            return (htmlList);
        }
コード例 #2
0
        // This is the actual method you call, it will calculate what's within the radius and return ViewModels
        public List<PresentedRestaurantUI> getRestaurantsWithinRadius(IncomingRequestUI request)
        {
            List<Restaurant> restaurantsWithinRadius = queryForRestaurantsAndCalculate(request);

            List<PresentedRestaurantUI> returnableModels = convertToViewModel(restaurantsWithinRadius);

            return returnableModels;
        }
コード例 #3
0
        // public static void getFilmDetails();
        public void demoMethod()
        {
            IncomingRequestUI request = new IncomingRequestUI();
            //fill request with user values

            //create finder object
            RestaurantFinder finder = new RestaurantFinder();
            //use finder to return list of viewmodels
            List<PresentedRestaurantUI> restaurantsInRadius = finder.getRestaurantsWithinRadius(request);
        }
コード例 #4
0
        // The returned list is ready to be put out over API and View
        public List<Restaurant> queryForRestaurantsAndCalculate(IncomingRequestUI request)
        {
            if (request == null)
                return null;

            restaurantsWithinRadius = new List<Restaurant>();

            // Find the lat/long (Point) of the IncomingRequestUI using FilmLocationsDAL
            Point requestPoint = null;
            List<Location> locationsForRequestedFilm = fdal.findLocationsByFilm(request.filmName);
            foreach (Location loc in locationsForRequestedFilm)
            {
                if (loc.locnText.Equals(request.location))
                {
                    requestPoint = loc.point;
                }
            }

            if (requestPoint == null)
                return null;

            // Find all restaurants
            List<Restaurant> allRestaurants = rdal.findAllRestaurants();

            // Create a Calculator obj
            LocationCalculator calc = new LocationCalculator();

            // Iterate through all restaurants in the DB
            for (int i = 0; i < allRestaurants.Count; i++)
            {
                // Passing the centre point, restaurant point and radius into the calculator
                calc.setNewQuery(requestPoint, allRestaurants[i].point, request.radius);
                // If the calculator decides the restarant is within the radius...
                if (calc.isInsideRadius())
                {
                    // ...add it to the outgoing list
                    restaurantsWithinRadius.Add(allRestaurants[i]);
                }
            }

            // Return the list of all Restaurants within radius
            return restaurantsWithinRadius;
        }