public void Insert(Question question) { if (question == null) { throw new ArgumentNullException(); } if (Get(question.Id) == null) { _context.Questions.Add(question); _context.SaveChanges(); } }
public int Insert(Answer answer) { if (answer == null) { throw new ArgumentNullException(); } if (Get(answer.Id) == null) { _context.Answers.Add(answer); _context.SaveChanges(); } return(answer.Id); }
public ClassController(QuizAppDbContext context) { _context = context; if (_context.Qa_class.Count() == 0) { _context.Qa_class.Add(new qa_class { qa_class_title = "intro 101", qa_class_description = "this is your first class" }); _context.SaveChanges(); } }
public UserController(QuizAppDbContext context) { _context = context; if (_context.Qa_users.Count() == 0) { _context.Qa_users.Add(new qa_users { qa_users_class_key = 0, qa_users_name = "name", qa_users_login = "******", qa_users_pass = "******", qa_users_email = "*****@*****.**", qa_users_score = 1, qa_users_correct = 0, qa_users_incorrect = 0, qa_users_isadmin = false }); _context.SaveChanges(); } }
public QuestionController(QuizAppDbContext context) { _context = context; if (_context.Qa_questions.Count() == 0) { _context.Qa_questions.Add(new qa_questions { qa_questions_class_key = 1, qa_questions_lesson_key = 1, qa_questions_question = "question", qa_questions_answer_1 = "A", qa_questions_answer_2 = "B", qa_questions_answer_3 = "C", qa_questions_answer_4 = "D", qa_questions_answer_5 = "E", qa_questions_correct = 0, qa_questions_incorrect = 0, }); _context.SaveChanges(); } }
public void Add(Test entity) { context.Add(entity); context.SaveChanges(); }
public void Add(TestResult entity) { context.TestResults.Add(entity); context.SaveChanges(); }
public void Add(Question entity) { context.Add(entity); context.SaveChanges(); }
public void Add(Genre entity) { context.Add(entity); context.SaveChanges(); }