private bool CheckIfExerciseDone() { bool isDone = false; if (_wordsAlreadyGuessedCount == _wordsToGuessCount && !_isOpenedFromModuleWindow) { _exerciseService.SetExerciseAsDone(_user, _exerciseNumber); // We want to set excersice as done only when it was opened from Lessons module if (_exerciseService.GetNextExercisesFromLesson(_user, _exerciseNumber).Count > 0) { MessageBox.Show(this, "Brawo! Zapisałeś poprawnie wszystkie słowa. \n Możemy teraz przejść do następnego ćwiczenia."); this.nextExerciseButton.IsEnabled = true; this.nextExerciseButton.Visibility = Visibility.Visible; } else if (_exerciseService.GetNextExercisesFromLesson(_user, _exerciseNumber).Count == 0) { MessageBox.Show(this, "Brawo! Ukończyłeś wszystkie ćwiczenia z tej lekcji."); _lessonService.SetLessonAsDone(_user, _exerciseNumber); int currentLessonNumber = _lessonService.GetLessonByUserAndExerciseNumber(_user, _exerciseNumber).lesson_number; int lastLessonNumber = _user.lessons.Select(l => l.lesson_number).Max(); if (currentLessonNumber < lastLessonNumber) { this.nextLessonButton.Visibility = Visibility.Visible; } } isDone = true; } else if (_wordsAlreadyGuessedCount == _wordsToGuessCount && _isOpenedFromModuleWindow) { if (_exerciseService.GetNextExercises(_user, _exerciseNumber).Count > 0) { MessageBox.Show(this, "Brawo! Zgadłeś wszystkie słowa. \nMożemy teraz przejść do następnego ćwiczenia."); this.nextExerciseButton.IsEnabled = true; this.nextExerciseButton.Visibility = Visibility.Visible; } else if (_exerciseService.GetNextExercises(_user, _exerciseNumber).Count == 0) { MessageBox.Show(this, "Niestety, to już wszystkie ćwiczenia."); } isDone = true; } return(isDone); }