public ActionResult Index(int?page)
        {
            _viewMessageLogic.SetViewMessageIfExist();
            TeacherId = GetTeacherId();
            var allAcademicYearsDetails = GetAllAcademicYearsDetail(TeacherId).Select(x => x.Id);

            IEnumerable <Homework> allHomeworks = _homeworkRepository.GetAllHomeworks().Where(x => allAcademicYearsDetails.Any(y => x.AcademicCourse != null && y == x.AcademicCourse.Id));


            IEnumerable <HomeworkDisplayModel> allHomeworkDisplaysModel =
                allHomeworks.Select(Mapper.Map <Homework, HomeworkDisplayModel>).ToList();
            const int pageSize   = 10;
            var       pageNumber = (page ?? 1);

            return(View(allHomeworkDisplaysModel.ToPagedList(pageNumber, pageSize)));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            _viewMessageLogic.SetViewMessageIfExist();
            TeacherId = GetTeacherId();
            var allAcademicYearsDetails = GetAllAcademicYearsDetail(TeacherId);
            var academicY            = new List <long>();
            var academicYearsDetails = allAcademicYearsDetails as AcademicYearDetail[] ?? allAcademicYearsDetails.ToArray();

            for (int a = 0; a < academicYearsDetails.Count(); a++)
            {
                academicY.Add(academicYearsDetails.ElementAt(a).Id);
            }
            IEnumerable <Homework>             allHomeworks             = _homeworkRepository.GetAllHomeworks().Where(x => academicY.Contains(x.AcademicYearDetail.Id));
            IEnumerable <DisplayHomeworkModel> allHomeworkDisplaysModel =
                allHomeworks.Select(Mapper.Map <Homework, DisplayHomeworkModel>).ToList();

            return(View(allHomeworkDisplaysModel));
        }