public ActionResult Index(string searchString, string sort)
        {
            ViewBag.Search = searchString;
            IEnumerable <Restaurant> rest;

            if (!String.IsNullOrEmpty(searchString))
            {
                rest = (CRUD.FindRestaurantByName(searchString));
            }
            else
            {
                rest = (CRUD.GetRestaurants());
            }


            if (!String.IsNullOrEmpty(searchString))
            {
                return(View(CRUD.FindRestaurantByName(searchString)));
            }



            ViewBag.NameSortParm       = sort == "name_asc" ? "name_desc" : "name_asc";
            ViewBag.TopRatingSortParm  = sort == "TopRating" ? "rating_top" : "TopRating";
            ViewBag.Top3RatingSortParm = sort == "Top3Rating" ? "rating_top3" : "Top3Rating";



            switch (sort)
            {
            case "name_desc":
                return(View(Sort1.SortDescending((List <Restaurant>)(CRUD.GetRestaurants()))));

                break;

            case "name_asc":
                return(View(Sort1.SortAscending((List <Restaurant>)(CRUD.GetRestaurants()))));

                break;

            case "rating_top":
                return(View(Sort1.SortTopRating((List <Restaurant>)(CRUD.GetRestaurants()))));

                break;

            case "rating_top3":
                return(View(Sort1.SortTop3Rating((List <Restaurant>)(CRUD.GetRestaurants()))));

                break;

            default:
                break;
            }
            return(View(rest));
        }
        // GET: Restaurant
        public ActionResult Index(string SearchString, string sort)
        {
            ViewBag.Search = SearchString;
            //IEnumerable<Restaurant> rest;
            if (!String.IsNullOrEmpty(SearchString))
            {
                View(da.SearchByPartialName(SearchString));
            }
            else
            {
                View(da.ShowRestaurants());
            }

            ViewBag.NameSortParm       = sort == "name_asc" ? "name_desc" : "name_asc";
            ViewBag.TopRatingSortParm  = sort == "rating_top" ? "rating_worst" : "rating_top";
            ViewBag.Top3RatingSortParm = sort == "rating_top3" ? "default" : "rating_top3";


            switch (sort)
            {
            case "name_desc":
                View(Sort1.SortDescending((List <Restaurant>)(da.ShowRestaurants())));
                break;

            case "name_asc":
                View(Sort1.SortAscending((List <Restaurant>)(da.ShowRestaurants())));
                break;

            case "rating_top":
                View(Sort1.SortTopRating((List <Restaurant>)(da.ShowRestaurants())));
                break;

            case "rating_worst":
                View(Sort1.SortWorstRating((List <Restaurant>)(da.ShowRestaurants())));
                break;

            case "rating_top3":
                View(Sort1.SortTop3Rating((List <Restaurant>)(da.ShowRestaurants())));
                break;

            default:
                break;
            }
            return(View());
        }
        public void SortTop3Rating()
        {
            reviews1.Add(review1);
            reviews1.Add(review2);
            reviews2.Add(review3);
            reviews2.Add(review4);
            reviews3.Add(review5);
            reviews3.Add(review6);

            restaurants.Add(rest1);
            restaurants.Add(rest2);
            restaurants.Add(rest3);

            List <Restaurant> sortedList = (List <Restaurant>)Sort1.SortTop3Rating(restaurants);
            Restaurant        actual     = restaurants[2];
            Restaurant        expected   = sortedList[0];

            Assert.AreEqual(expected, actual);
        }