Exemple #1
0
        public ActionResult CourseResponses(string urlName, int?pageIndex)
        {
            if (!pageIndex.HasValue)
            {
                return(RedirectToAction(() => CourseResponses(urlName, 1)));
            }
            var course = CourseService.GetAll(c => c.IsActive && c.UrlName == urlName)
                         .OrderBy(x => x.Course_ID).FirstOrDefault();

            if (course == null)
            {
                return(null);
            }
            var responses = ResponseService.GetAllForCourse(course.Course_TC)
                            .OrderByDescending(x => x.Rating)
                            .ThenByDescending(x => x.UpdateDate).ToPagedList(pageIndex.GetValueOrDefault(1) - 1, 10);
            var orgResponses =
                OrgResponseService.GetAll(r => r.Course_TC == course.Course_TC)
                .Take(20).ToList();
            var model = new CourseResponsesVM {
                Course       = course,
                Responses    = responses,
                OrgResponses = orgResponses
            };

            return(View(ViewNames.CourseResponses, model));
        }