Beispiel #1
0
        private async Task UpdateDescription(StudentEntity student)
        {
            if (student == null)
            {
                RunInUiThread(() => { this.ActiveStudentInfoVisibility = Visibility.Collapsed; });
                return;
            }

            var  now                    = DateTime.Now;
            var  missedLessons          = _db.GetStudentMissedLessons(student, this.Lesson.Stream, now);
            var  discipline             = this.Lesson?.Stream?.Discipline;
            long additionalLessonsCount = discipline != null
                ? await _db.GetAdditionalLessonsByDiscipline(student, discipline).CountAsync()
                : await _db.GetAllAdditionalLessons(student).CountAsync();

            var missedLectures = missedLessons.Where
                                 (
                lessonModel => lessonModel.Lesson.LessonType == LessonType.Lecture
                                 );
            var missedPractices = missedLessons
                                  .Where
                                  (
                lessonModel => lessonModel.Lesson.LessonType == LessonType.Practice
                                  );
            var missedLabs = missedLessons
                             .Where
                             (
                lessonModel => lessonModel.Lesson.LessonType == LessonType.Laboratory
                             );
            var loadStudentPhoto = await LoadStudentPhoto(student);

            RunInUiThread(() => {
                this.ActiveStudentInfoVisibility = Visibility.Visible;
                this.StudentDescription          = new StudentDescription {
                    Photo                 = loadStudentPhoto,
                    LastName              = student.LastName,
                    FirstName             = student.FirstName,
                    SecondName            = student.SecondName,
                    AdditionalLessonsInfo = additionalLessonsCount == default ? "" : $"+{additionalLessonsCount}",
                    GroupName             = string.Join(", ", student.Groups?.Select(group => group.Name) ?? new List <string>())
                                            .Trim(),
                    LessonStat = string.Format(Localization["page.registration.active.student.info"],
                                               missedLessons.Count,
                                               missedLectures.Count(),
                                               missedPractices.Count(),
                                               missedLabs.Count()),
                };
            });
        }
        private void OnSelectedStreamUpdate([CanBeNull] StreamEntity stream)
        {
            if (stream == null)
            {
                this.StreamDataVisibility = Visibility.Hidden;
                return;
            }

            this.StreamDataVisibility = Visibility.Visible;
            InterpolateLocalization
            (
                "page.student.view.stream.course",
                stream.Course?.ToString() ?? ""
            );
            InterpolateLocalization
            (
                "page.student.view.discipline.lessons",
                stream.LectureCount,
                stream.PracticalCount,
                stream.LabCount
            );
            var missedLessons   = _context.GetStudentMissedLessons(this.Student, stream, DateTime.Now);
            var missedLectures  = missedLessons.Count(model => model.Lesson.LessonType == LessonType.Lecture);
            var missedPractices = missedLessons.Count(model => model.Lesson.LessonType == LessonType.Practice);
            var missedLabs      = missedLessons.Count(model => model.Lesson.LessonType == LessonType.Laboratory);
            var total           = missedLectures + missedPractices + missedLabs;

            this.StudentMissedLessons = total == 0
                ? Localization["Нет пропущенных занятий"]
                : LocalizationContainer.Interpolate
                                        (
                "page.student.view.missed.lessons",
                total,
                missedLectures,
                missedPractices,
                missedLabs
                                        );
        }