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()), }; }); }