Exemple #1
0
        public string SearchRestaurant(string restaurantName)
        {
            List <RestaurantDL.Restaurant> restaurants = new List <RestaurantDL.Restaurant>();

            restaurants = dbu.GetRestaurants().ToList();

            List <RestaurantDL.Restaurant> restaurants2 = new List <RestaurantDL.Restaurant>();

            foreach (var restaurant in restaurants)
            {
                if (restaurant.name.Contains(restaurantName))
                {
                    restaurants2.Add(restaurant);
                }
            }
            return(JsonConvert.SerializeObject(restaurants2)); //return modified list of restaurants containing restaurantName
        }
Exemple #2
0
        public static List <Restaurant> DisplayAllRestaurants()
        {
            List <Restaurant> restaurants = new List <Restaurant>();

            restaurants = DButilities.GetRestaurants().ToList();

            restaurants = restaurants.OrderBy(x => x.name).ToList();
            return(restaurants);
        }
Exemple #3
0
        public static List <Restaurant> SortByRating()
        {
            List <Restaurant> restaurants = new List <Restaurant>();

            restaurants = DButilities.GetRestaurants().ToList();

            restaurants = restaurants.OrderByDescending(x => x.AvgRating).ToList();
            return(restaurants);
        }
        public List <RestaurantDL.Restaurant> DisplayTop3()
        {
            DButilities dbutilities = new DButilities();
            //var query = (from r in dbutilities.Restaurants
            //             orderby r.AvgRating descending
            //             select r).Take(3);
            //Console.WriteLine("Here are the top 3 Restaurants:");

            var topthree = dbutilities.GetRestaurants().OrderByDescending(x => x.AvgRating).Take(3);

            return(topthree.ToList());
        }
Exemple #5
0
 // GET: Restaurants
 public ActionResult Index()
 {
     ViewBag.restaurants = dbutilities.GetRestaurants();
     return(View());
 }