Exemple #1
0
 public static void InsertQuestions(List <Question> questions)
 {
     using (var db = new QuizDBContext())
     {
         db.Questions.AddRange(questions);
         db.SaveChanges();
     }
 }
Exemple #2
0
 public static void InsertUsers(List <User> users)
 {
     using (var db = new QuizDBContext())
     {
         db.Users.AddRange(users);
         db.SaveChanges();
     }
 }
Exemple #3
0
 public static void InsertCategories(List <Category> categories)
 {
     using (var db = new QuizDBContext())
     {
         db.Categories.AddRange(categories);
         db.SaveChanges();
     }
 }
Exemple #4
0
        public static void DeleteAllData()
        {
            using (var db = new QuizDBContext())
            {
                foreach (var usr in db.Users)
                {
                    db.Users.Remove(usr);
                }
                foreach (var cat in db.Categories)
                {
                    db.Categories.Remove(cat);
                }
                foreach (var question in db.Questions)
                {
                    db.Questions.Remove(question);
                }
                foreach (var answer in db.Answers)
                {
                    db.Answers.Remove(answer);
                }

                db.SaveChanges();
            }
        }