//Display all courses with filters // GET: /Courses/DisplayCourses public ActionResult DisplayCourses(string currentFilter, string statusFilter, string themeFilter, string lectorFilter, int?page) { logManager.AddEventLog("CoursesController => DisplayCourses ActionResult called(GET)", "ActionResult"); ViewBag.CurrentFilter = currentFilter; ViewBag.CurrentStatusFilter = statusFilter; ViewBag.CurrentThemeFilter = themeFilter; ViewBag.CurrentLectorFilter = lectorFilter; ViewBag.Themes = new SelectList(coursesManager.GetAllThemes(themeFilter)); ViewBag.Status = new SelectList(new List <string> { "All", "Upcoming", "Active", "Ended" }); int pageSize = 10; int pageNumber = (page ?? 1); var coursesList = coursesManager.GetCourses(); if (Request.HttpMethod == "POST") { coursesList = coursesManager.GetSortedCourses(currentFilter, statusFilter, themeFilter, lectorFilter, null, coursesList); var coursesPost = CourseViewModel.GetCoursesList(coursesList, 1); ViewBag.Lectors = new SelectList(usersManager.GetAllLectorsString( coursesPost.Select(c => c.Lector).ToList(), lectorFilter), lectorFilter); return(View(coursesPost.ToPagedList(pageNumber, pageSize))); } coursesList = coursesManager.GetSortedCourses(currentFilter, statusFilter, themeFilter, lectorFilter, null, coursesList); var courses = CourseViewModel.GetCoursesList(coursesList, 1); ViewBag.Lectors = new SelectList(usersManager.GetAllLectorsString( courses.Select(c => c.Lector).ToList(), lectorFilter), lectorFilter); return(View(courses.ToPagedList(pageNumber, pageSize))); }