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

                    EditStudentWindow editStudentWindow = new EditStudentWindow(
                        client.GetStudentById(studentId));
                    if (editStudentWindow.ShowDialog() == true)
                    {
                        var    student = editStudentWindow.Student;
                        string secret  = Crypto.GenerateRandomSecret();
                        student.Username     = Crypto.EncryptStringAES(student.Username, secret);
                        student.PasswordHash = Crypto.EncryptStringAES(student.PasswordHash, secret);

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

                    EditStudentWindow editStudentWindow = new EditStudentWindow(
                        client.GetStudentById(studentId));
                    if (editStudentWindow.ShowDialog() == true)
                    {
                        var student = editStudentWindow.Student;
                        string secret = Crypto.GenerateRandomSecret();
                        student.Username = Crypto.EncryptStringAES(student.Username, secret);
                        student.PasswordHash = Crypto.EncryptStringAES(student.PasswordHash, secret);

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