コード例 #1
0
 public ProfessorDashboardViewModel GetProfessorDashboard(FilterViewModel filter = null)
 {
     var viewModel = ApplyFilter(filter ?? GetDefaultFilter());
     return viewModel;
 }
コード例 #2
0
 private static ProfessorDashboardViewModel DefaultProfessorDashboard(FilterViewModel filterViewModel)
 {
     return new ProfessorDashboardViewModel() {Filter = filterViewModel};
 }
コード例 #3
0
        private ProfessorDashboardViewModel ApplyFilter(FilterViewModel filterViewModel)
        {
            var groupId = GetSelectedId(filterViewModel.Group);
            var semesterSeqId = GetSelectedId(filterViewModel.SemesterSeq);
            if (!groupId.HasValue || !semesterSeqId.HasValue)
            {
                return DefaultProfessorDashboard(filterViewModel);
            }

            var students = groupService.GetGroupStudents(groupId.Value);
            if (!students.Any())
            {
                return DefaultProfessorDashboard(filterViewModel);
            }
            var curriculum = curriculumService.GetCurriculumForStudent(students.First());
            if (!curriculum.Semesters.Any(p => p.Sequential == semesterSeqId.Value))
            {
                return DefaultProfessorDashboard(filterViewModel);
            }

            var subjects = curriculum.Semesters.First(p => p.Sequential == semesterSeqId.Value).Subjects;

            return new ProfessorDashboardViewModel
            {
                Filter = filterViewModel,
                CountSubjects = subjects.Count,
                Students = students.Select(stud =>
                {
                    var student = studentProfileService.CreateOrOpen(stud);
                    return new StudentRowViewModel
                    {

                        Student = string.Format("{0} {1}", student.LastName, student.FirstName),
                        StudentId = student.Id,
                        Subjects = subjects.Select(subj =>
                        {
                            var studentTheme = studentThemeService.All().SingleOrDefault(p => p.SubjectId == subj.Id && p.StudentId == stud);
                            var subject = new StudentSubjectViewModel
                            {
                                Subject = subj.Name,
                                SubjectId = subj.Id
                            };

                            if (studentTheme != null)
                            {
                                subject.Theme = Mapper.Map<SelectedItemModel,SelectedItemViewModel>(themeService.GetSelectedItemById(studentTheme.ThemeId));
                                subject.ThemeId = studentTheme.ThemeId;
                            }
                            // if exist theme for this subject set it
                            return subject;
                        }).ToList()
                    };
                }).ToList()
            };
        }
コード例 #4
0
 public JsonResult GetProfessorDashboard(FilterViewModel filter)
 {
     return Json(dashboardManagementService.GetProfessorDashboard(filter));
 }