private void CreateSubjectButton_Click(object sender, RoutedEventArgs e) { if (SubjectName.Text != "") { bool isCorrect = true; foreach (var n in subjects) { if (SubjectName.Text == n.SubjectName) { isCorrect = false; } } if (isCorrect) { string subjectName = SubjectName.Text; string answer = client.AddSubject(subjectName); if (answer == "succesfull") { main.Content = new AdminSubjects(client, mw, main); } } else { MessageBox.Show("This item already exists!"); } } else { MessageBox.Show("Please enter subject name!"); } }