コード例 #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
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
 // GET: Restaurants
 public ActionResult Index()
 {
     ViewBag.restaurants = dbutilities.GetRestaurants();
     return(View());
 }