Beispiel #1
0
 private void ButtonAdd_Click()
 {
     if (!String.IsNullOrWhiteSpace(TextBoxQuestion.Text) &&
         !String.IsNullOrWhiteSpace(TextBoxAnswer1.Text) &&
         !String.IsNullOrWhiteSpace(TextBoxAnswer2.Text) &&
         !String.IsNullOrWhiteSpace(TextBoxAnswer3.Text) &&
         !String.IsNullOrWhiteSpace(TextBoxAnswer4.Text) &&
         !String.IsNullOrWhiteSpace(TextBoxQuestionNumber.Text))
     {
         var newquestion = new QuestionModel1
         {
             Question       = TextBoxQuestion.Text,
             QuestionNumber = int.Parse(TextBoxQuestionNumber.Text),
             Answer1        = TextBoxAnswer1.Text,
             Answer2        = TextBoxAnswer2.Text,
             Answer3        = TextBoxAnswer3.Text,
             Answer4        = TextBoxAnswer4.Text,
             TopicId        = edcl.SelectedTopic.Id
         };
         if (RadioButton1.IsChecked == true)
         {
             newquestion.CorrectAnswer = newquestion.Answer1;
         }
         if (RadioButton2.IsChecked == true)
         {
             newquestion.CorrectAnswer = newquestion.Answer2;
         }
         if (RadioButton3.IsChecked == true)
         {
             newquestion.CorrectAnswer = newquestion.Answer3;
         }
         if (RadioButton4.IsChecked == true)
         {
             newquestion.CorrectAnswer = newquestion.Answer4;
         }
         edcl.AddQuestion1(newquestion);
         Clear();
     }
 }
Beispiel #2
0
 public void AddQuestion1(QuestionModel1 newquestion)
 {
     ctx.Questions1.AddOrUpdate(q => q.Question, newquestion);
     ctx.SaveChanges();
     Update("../../../../EducationApp.Classes/Data", "Questions1.json", ctx.Questions1.ToList());
 }