private void Button_Click(object sender, RoutedEventArgs e) { _testSession.EndTime = DateTime.Now; var i = 0; foreach (var question in questions) { if (!string.IsNullOrEmpty(question.QuestionAnswer)) { var answer = new DTOAnswer(); string userAswerFromForm; answerDictionary.TryGetValue(i, out userAswerFromForm); answer.AnswerCorrects = CompateAnswers(question.QuestionAnswer, userAswerFromForm); answer.AnswerText = userAswerFromForm; answer.QuestionId = question.Id; answer.TestSessionId = _testSession.TestSessionId; _userAnswers.Add(answer); } i++; } List <int> answersId = client.AddStudentsAnswers(_userAnswers); _testSession.AnswersId = answersId; client.UpdateTestSession(_testSession); //this.DataContext = null; this.Visibility = Visibility.Hidden; //NavigationService.Navigate(_previousPage); main.Content = new StudentTests(client, mw, main); mw.Visibility = Visibility.Visible; }