private void btnEditTeacher_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.dataGridTeachers.SelectedIndex == -1)
                {
                    MessageBox.Show("Не сте избрали учител");
                }
                else if (this.dataGridTeachers.SelectedItems.Count > 1)
                {
                    MessageBox.Show("Трябва да изберете един учител");
                }
                else
                {
                    int teacherId = (this.dataGridTeachers.SelectedItem as dynamic).Id;

                    EditTeacherWindow editTeacherWindow = new EditTeacherWindow(
                        client.GetTeacherById(teacherId));

                    if (editTeacherWindow.ShowDialog() == true)
                    {
                        var    teacher = editTeacherWindow.Teacher;
                        string secret  = Crypto.GenerateRandomSecret();
                        teacher.Username     = Crypto.EncryptStringAES(teacher.Username, secret);
                        teacher.PasswordHash = Crypto.EncryptStringAES(teacher.PasswordHash, secret);

                        if (client.EditTeacher(teacherId, teacher, secret))
                        {
                            UpdateTeacherViews();
                            MessageBox.Show("Учителят беше редактиран успешно");
                        }
                        else
                        {
                            MessageBox.Show(
                                "Учителят НЕ беше редактиран успешно поради грешно въведена информация");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.Resources["defaultErrorMessage"].ToString(),
                                "Грешка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnEditTeacher_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if(this.dataGridTeachers.SelectedIndex == -1)
                {
                    MessageBox.Show("Не сте избрали учител");
                }
                else if(this.dataGridTeachers.SelectedItems.Count > 1)
                {
                    MessageBox.Show("Трябва да изберете един учител");
                }
                else
                {
                    int teacherId = (this.dataGridTeachers.SelectedItem as dynamic).Id;

                    EditTeacherWindow editTeacherWindow = new EditTeacherWindow(
                        client.GetTeacherById(teacherId));

                    if(editTeacherWindow.ShowDialog() == true)
                    {
                        var teacher = editTeacherWindow.Teacher;
                        string secret = Crypto.GenerateRandomSecret();
                        teacher.Username = Crypto.EncryptStringAES(teacher.Username, secret);
                        teacher.PasswordHash = Crypto.EncryptStringAES(teacher.PasswordHash, secret);

                        if (client.EditTeacher(teacherId, teacher, secret))
                        {
                            UpdateTeacherViews();
                            MessageBox.Show("Учителят беше редактиран успешно");
                        }
                        else
                        {
                            MessageBox.Show(
                                "Учителят НЕ беше редактиран успешно поради грешно въведена информация");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.Resources["defaultErrorMessage"].ToString(), 
                    "Грешка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }