Esempio n. 1
0
        public int SaveQuestion(IEnumerable <Question> questions)
        {
            using (var context = new EnglishQuestionContext())
            {
                foreach (var question in questions)
                {
                    context.Entry(question).State = (question.Id == 0) ? EntityState.Added : EntityState.Modified;

                    foreach (var answer in question.Answers)
                    {
                        context.Entry(answer).State = (answer.Id == 0) ? EntityState.Added : EntityState.Modified;
                    }
                }
                return(context.SaveChanges());
            }
        }
Esempio n. 2
0
 public void DeleteParagraph(Paragraph paragraph)
 {
     using (var context = new EnglishQuestionContext())
     {
         foreach (var question in paragraph.Questions.ToList())
         {
             foreach (var answer in question.Answers.ToList())
             {
                 context.Entry(answer).State = EntityState.Deleted;
             }
             context.Entry(question).State = EntityState.Deleted;
         }
         context.Entry(paragraph).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public void DeleteB1B2Config(B1B2ConfigValue configValue)
 {
     using (var context = new EnglishQuestionContext())
     {
         context.Entry(configValue).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 4
0
 public int SaveSubTest(SubTest subTest)
 {
     using (var context = new EnglishQuestionContext())
     {
         context.Entry(subTest).State = EntityState.Modified;
         return(context.SaveChanges());
     }
 }
Esempio n. 5
0
 public void SynchorizedTests(IEnumerable <Test> tests)
 {
     using (var context = new EnglishQuestionContext())
     {
         foreach (var test in tests)
         {
             context.Entry(test).State = EntityState.Modified;
         }
         context.SaveChanges();
     }
 }