Ejemplo n.º 1
0
 public static void UpdateTest(Test test)
 {
     using (var db = new TestSystemEntities())
     {
         db.Tests.Add(test);
         var entry = db.Entry(test);
         entry.State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public static void UpdateTestQuestions(Question[] questions)
 {
     if (questions == null) return;
     using (var db = new TestSystemEntities())
     {
         foreach (var item in questions)
         {
             db.Questions.Add(item);
             var entry = db.Entry(item);
             entry.State = EntityState.Modified;
         }
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public static void AddQuestion(int test, Question q)
        {
            using (var db = new TestSystemEntities())
            {
                db.Questions.Add(q);
                var entry = db.Entry(q);
                entry.State = EntityState.Added;
                db.SaveChanges();

                TestQuestion t = new TestQuestion()
                {
                    QuestionId = q.Id,
                    TestId = test
                };
                db.TestQuestions.Add(t);
                db.SaveChanges();
            }
        }