//Display all courses // GET: /Admin/ManageCourses/DisplayCourses public ActionResult DisplayCourses(string statusFilter, string themeFilter, string lectorFilter, string courseNameFilter, int?page, string statusMessage) { logManager.AddEventLog("ManageCoursesController(Admin area) => DisplayCourses ActionResult called(GET)", "ActionResult"); ViewBag.StatusMessage = statusMessage; ViewBag.CurrentStatusFilter = statusFilter; ViewBag.CurrentThemeFilter = themeFilter; ViewBag.CurrentLectorFilter = lectorFilter; ViewBag.CourseNameFilter = courseNameFilter; ViewBag.Themes = new SelectList(coursesManager.GetAllThemes(themeFilter)); ViewBag.Status = new SelectList(new List <string> { "All", "Unknown", "Upcoming", "Active", "Ended" }); int pageSize = 10; int pageNumber = (page ?? 1); var coursesList = coursesManager.GetCoursesForAdmin(); if (Request.HttpMethod == "POST") { coursesList = coursesManager.GetSortedCourses(null, statusFilter, themeFilter, lectorFilter, courseNameFilter, coursesList); var coursesPost = CourseViewModel.GetCoursesList(coursesList, 1); ViewBag.CurrentStatusFilter = statusFilter; ViewBag.CurrentThemeFilter = themeFilter; ViewBag.CurrentLectorFilter = lectorFilter; ViewBag.CourseNameFilter = courseNameFilter; ViewBag.Lectors = new SelectList(usersManager.GetAllLectorsString( coursesPost.Select(c => c.Lector).ToList(), lectorFilter), lectorFilter); return(View(coursesPost.ToPagedList(pageNumber, pageSize))); } coursesList = coursesManager.GetSortedCourses(null, statusFilter, themeFilter, lectorFilter, courseNameFilter, 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))); }