public StudentSummaryInfo GetStudentSummaryInfo(int studentId)
        {
            var classRank = new ClassRank
            {
                StudentId = studentId,
                ClassSize = 10
            };

            var syId = Context.SchoolYearId ?? ServiceLocator.SchoolYearService.GetCurrentSchoolYear().Id;

            var discipline = ((DemoDisciplineService)ServiceLocator.DisciplineService).GetList(DateTime.Today);

            var infractions = new List <StiConnector.Connectors.Model.Infraction>();

            foreach (var disciplineReferral in discipline.Where(disciplineReferral => disciplineReferral.Infractions != null))
            {
                infractions.AddRange(disciplineReferral.Infractions);
            }

            var chlkInfractions = ServiceLocator.InfractionService.GetInfractions();

            var infractionSummaries = from infr in infractions
                                      group infr by infr.Id
                                      into g
                                      select new { Id = g.Key, Count = g.Count() };

            var attendances =
                ((DemoAttendanceService)ServiceLocator.AttendanceService).GetStudentAbsenceSummary(studentId);

            var infractionSummary = infractionSummaries.Select(x => new InfractionSummary
            {
                StudentId    = studentId,
                InfractionId = x.Id,
                Occurrences  = x.Count
            }).ToList();

            var nowDashboard = new NowDashboard
            {
                ClassRank         = classRank,
                Infractions       = infractionSummary,
                SectionAttendance = new List <StudentSectionAbsenceSummary>(), //attendances,
                Scores            = ((DemoStudentAnnouncementService)ServiceLocator.StudentAnnouncementService).GetActivityScoresForStudent(studentId)
            };
            var student       = GetStudentDetails(studentId, syId);
            var activitiesids = nowDashboard.Scores.GroupBy(x => x.ActivityId).Select(x => x.Key).ToList();

            //TODO: impl
            var anns = new List <AnnouncementComplex>(); //((DemoAnnouncementService) ServiceLocator.ClassAnnouncementService).GetByActivitiesIds(activitiesids);
            var res  = StudentSummaryInfo.Create(student, nowDashboard, chlkInfractions, anns, MapperFactory.GetMapper <StudentAnnouncement, Score>());

            return(res);
        }
Beispiel #2
0
        public async Task <StudentSummaryInfo> GetStudentSummaryInfo(int studentId, int schoolYearId)
        {
            Trace.Assert(Context.SchoolLocalId.HasValue);
            Trace.Assert(Context.PersonId.HasValue);

            var nowDashboardTask = ConnectorLocator.StudentConnector.GetStudentNowDashboard(schoolYearId, studentId, Context.NowSchoolTime);
            var student          = ServiceLocator.StudentService.GetById(studentId, schoolYearId);
            var infractions      = ServiceLocator.InfractionService.GetInfractions();
            var nowDashboard     = await nowDashboardTask;

            var activitiesIds = nowDashboard.Scores.GroupBy(x => x.ActivityId).Select(x => x.Key).ToList();
            var anns          = DoRead(uow => new ClassAnnouncementForTeacherDataAccess(uow, schoolYearId).GetByActivitiesIds(activitiesIds, Context.PersonId.Value));

            anns = anns.Where(x => x.ClassAnnouncementData.VisibleForStudent).ToList();
            var res = StudentSummaryInfo.Create(student, nowDashboard, infractions, anns, MapperFactory.GetMapper <StudentAnnouncement, Score>());

            return(res);
        }