public void Add(QuestionsDataModel questionsDataModel) { Questions Question = new Questions { Id = questionsDataModel.Id, QuestionText = questionsDataModel.QuestionText, DifficultyLevelId = questionsDataModel.DifficultyLevelId, }; ContextGateway <Questions> .CreateDatabaseTransaction(); ContextGateway <Questions> .Add(Question); foreach (QuestionAnswersDataModel questionAnswers in questionsDataModel.QuestionAnswersDataModel) { ContextGateway <Questions> .Add( new QuestionAnswers { Id = questionAnswers.Id, AnswerText = questionAnswers.AnswerText, IsCorrect = questionAnswers.IsCorrext, QuestionId = Question.Id }); } ContextGateway <Questions> .Commit(); }
public void Add(DifficultyLevelsDataModel difficultyLevels) { DifficultyLevels difficultyLevelsInstance = new DifficultyLevels(); difficultyLevelsInstance.DifficultyLevelName = difficultyLevels.DifficultyLevelName; ContextGateway <DifficultyLevels> .Add(difficultyLevelsInstance); }