Exemple #1
0
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page, int pagesize = 10)
        {
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.ResultAmount = pagesize;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "Film" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var films = _reserveringRepository.GetAll( );

            if (!String.IsNullOrEmpty(searchString))
            {
                films = _search.GetReservationWith(searchString);
            }
            switch (sortOrder)
            {
            case "Film":
                films = films.OrderBy(f => f.Film.Naam).ToList( );
                break;

            default:
                films = films.OrderByDescending(b => b.Film.Naam).ToList( );
                break;
            }
            int pageSize   = pagesize;
            int pageNumber = (page ?? 1);

            return(View(films.ToPagedList(pageNumber, pageSize)));
        }