Пример #1
0
        public void Add(ExamTypesDataModel examTypesDataModel)
        {
            ExamTypes examTypes;

            examTypes = new ExamTypes
            {
                Id                = examTypesDataModel.Id,
                ExamTypeName      = examTypesDataModel.ExamTypeName,
                DifficultyLevelId = examTypesDataModel.DifficultyLevelId,
                NumberOfQuestions = examTypesDataModel.NumberOfQuestions
            };
            _contextGateWay.CreateDatabaseTransaction();

            _contextGateWay.ExamTypes.Add(examTypes);
            foreach (ExamTypesDetailsDataModel examTypesDetails in examTypesDataModel.examTypesDetails)
            {
                _contextGateWay.ExamTypesDetails.Add(
                    new ExamTypesDetails
                {
                    DifficultyLevelId = examTypesDetails.DifficultyLevelId,
                    NumberOfQuestions = examTypesDetails.NumberOfQuestions,
                    ExamTypeId        = examTypes.Id
                });
            }
            _contextGateWay.Commit();
        }
Пример #2
0
        public void Add(QuestionsDataModel questionsDataModel)
        {
            Questions Question = new Questions
            {
                Id                = questionsDataModel.Id,
                QuestionText      = questionsDataModel.QuestionText,
                DifficultyLevelId = questionsDataModel.DifficultyLevelId,
            };

            _contextGateWay.CreateDatabaseTransaction();
            _contextGateWay.Questions.Add(Question);
            foreach (QuestionAnswersDataModel questionAnswers in questionsDataModel.QuestionAnswersDataModel)
            {
                _contextGateWay.QuestionAnswers.Add(
                    new QuestionAnswers
                {
                    Id         = questionAnswers.Id,
                    AnswerText = questionAnswers.AnswerText,
                    IsCorrect  = questionAnswers.IsCorrext,
                    QuestionId = Question.Id
                });
            }
            _contextGateWay.Commit();
        }