コード例 #1
0
        public async Task <IResponse> ImportStudyGroupMembershipsAsync(IEnumerable <Student> currentStudents, short year, short section)
        {
            var studyGroups = await schildExporter.GetStudyGroupsAsync(currentStudents, year, section).ConfigureAwait(false);

            var membershipData = new List <StudyGroupMembershipData>();

            if (OnlyVisibleEntities)
            {
                studyGroups = studyGroups.RemoveInvisibleGrades().Where(x => x.Grades.Count > 0).ToList();
            }

            foreach (var studyGroup in studyGroups)
            {
                foreach (var membership in studyGroup.Memberships)
                {
                    membershipData.Add(new StudyGroupMembershipData
                    {
                        StudyGroup = IdResolver.Resolve(studyGroup),
                        Student    = membership.Student.Id.ToString(),
                        Type       = membership.Type
                    });
                }
            }

            return(await iccImporter.ImportStudyGroupMembershipsAsync(membershipData));
        }
コード例 #2
0
        public async Task <IResponse> ImportStudyGroupsAsync(IEnumerable <Student> currentStudents, short year, short section, bool importMemberships)
        {
            var studyGroups = await schildExporter.GetStudyGroupsAsync(currentStudents, year, section).ConfigureAwait(false);

            if (OnlyVisibleEntities)
            {
                studyGroups = studyGroups.RemoveInvisibleGrades().Where(x => x.Grades.Count > 0).ToList();
            }

            var data = studyGroups
                       .Where(x => x != null)
                       .Select(studyGroup =>
            {
                return(new StudyGroupData
                {
                    Id = IdResolver.Resolve(studyGroup),
                    Name = NameResolver.Resolve(studyGroup),
                    Type = studyGroup.Type == StudyGroupType.Course ? "course" : "grade",
                    Grades = studyGroup.Grades.Select(grade => grade.Name).ToList(),
                });
            })
                       .ToList();

            return(await iccImporter.ImportStudyGroupsAsync(data));
        }
コード例 #3
0
        public async Task <IResponse> ImportTuitionsAsync(IEnumerable <Student> currentStudents, short year, short section)
        {
            logger.LogDebug("Hole Unterrichte aus SchILD...");
            var tuitions = await schildExporter.GetTuitionsAsync(currentStudents, year, section);

            logger.LogDebug($"{tuitions.Count} Unterricht(e) geladen.");

            if (OnlyVisibleEntities)
            {
                logger.LogDebug("Ausgeblendete Lehrkräfte entfernen.");
                tuitions = tuitions.RemoveInvisibleTeachers().ToList();
            }

            var studyGroups = await schildExporter.GetStudyGroupsAsync(currentStudents, year, section);

            if (OnlyVisibleEntities)
            {
                studyGroups = studyGroups.RemoveInvisibleGrades().Where(x => x.Grades.Count > 0).ToList();
            }

            var data = tuitions
                       .RemoveInvisibleTeachers()
                       .Where(x => x.StudyGroupRef != null)
                       .Select(tuition =>
            {
                var studyGroup = studyGroups.FirstOrDefault(x => x.Id == tuition.StudyGroupRef.Id && x.Name == tuition.StudyGroupRef.Name);

                return(new TuitionData
                {
                    Id = IdResolver.Resolve(tuition, studyGroup),
                    Name = NameResolver.Resolve(tuition),
                    DisplayName = studyGroup.DisplayName,
                    Subject = tuition.SubjectRef.Id.ToString(),
                    Teacher = tuition.TeacherRef?.Acronym,
                    AdditionalTeachers = tuition.AdditionalTeachersRef.Select(teacher => teacher.Acronym).ToList(),
                    StudyGroup = IdResolver.Resolve(studyGroup)
                });
            })
                       .ToList();

            return(await iccImporter.ImportTuitionsAsync(data));
        }