Ejemplo n.º 1
0
        public ActionResult DisplayCoursesForLector(string userId, string statusFilter, string themeFilter, string courseNameFilter, int?page)
        {
            logManager.AddEventLog("ManageController => DisplayCoursesForLector ActionResult called(GET)", "ActionResult");
            ViewBag.UserId = userId ?? throw new ArgumentNullException();
            ViewBag.CurrentStatusFilter = statusFilter;
            ViewBag.CurrentThemeFilter  = themeFilter;
            ViewBag.CourseNameFilter    = courseNameFilter;
            ViewBag.Themes = new SelectList(coursesManager.GetAllThemes(themeFilter));
            ViewBag.Status = new SelectList(new List <string> {
                "All", "Unknown", "Upcoming", "Active", "Ended"
            });
            int pageSize    = 5;
            int pageNumber  = (page ?? 1);
            var coursesList = coursesManager.GetCoursesForLector(userId);

            if (Request.HttpMethod == "POST")
            {
                coursesList = coursesManager.GetSortedCourses(null, statusFilter, themeFilter, null, courseNameFilter, coursesList);
                List <CourseViewModel> coursesPost = CourseViewModel.GetCoursesList(coursesList, 2);

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

            coursesList = coursesManager.GetSortedCourses(null, statusFilter, themeFilter, null, courseNameFilter, coursesList);
            List <CourseViewModel> courses = CourseViewModel.GetCoursesList(coursesList, 2);


            return(View(courses.ToPagedList(pageNumber, pageSize)));
        }
Ejemplo n.º 2
0
        //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)));
        }