private void Save_Click(object sender, RoutedEventArgs e)
        {
            QuestionTextValidator validator = new QuestionTextValidator();

            if (!validator.Validate(textBoxQuestion.Text))
            {
                MessageBox.Show("A kérdés szövege nem lehet üres, és nem tartalmazhat speciális karaktert!", "Hiba!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            string     questionText = textBoxQuestion.Text.Trim();
            Hemisphere hemisphere   = radioLeft.IsChecked.Value ? Hemisphere.Left : Hemisphere.Right;
            bool       isAdult      = radioAdult.IsChecked.Value;

            Question question = new Question
            {
                Text       = questionText,
                IsAdult    = isAdult,
                Hemisphere = hemisphere
            };

            using (QuestionManager questionManager = new QuestionManager())
            {
                questionManager.AddQuestion(question);
            }

            MessageBox.Show("Sikeres mentés!", "Mentés", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #2
0
        private void ButtonSaveQuestion_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            QuestionTextValidator validator = new QuestionTextValidator();
            Question question = SelectedQuestion;

            if (question == null)
            {
                MessageBox.Show("Válasszon ki egy kérdést!", "Hiba!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            else if (!validator.Validate(textBoxQuestion.Text))
            {
                MessageBox.Show("A kérdés szövege nem lehet üres, és nem tartalmazhat speciális karaktert!", "Hiba!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            question.Text       = textBoxQuestion.Text.Trim();
            question.IsAdult    = radioAdult.IsChecked.Value;
            question.Hemisphere = radioLeft.IsChecked.Value ? Hemisphere.Left : Hemisphere.Right;

            questionManager.SaveChanges();

            MessageBox.Show("Sikeres mentés!", "Mentés", MessageBoxButton.OK, MessageBoxImage.Information);

            PopulateListBoxQuestion();
        }