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); }
public QuestionsDataModel GetById(int id) { //repositoryGateWay = new RepositoryGateWay<Questions>(); //RepositoryGateWay<QuestionAnswers> QuestionAnswersRepositoryGateWay; Questions questions = ContextGateway <Questions> .GetById(e => e.Id == id); //QuestionAnswersRepositoryGateWay = new RepositoryGateWay<QuestionAnswers>(); questions.QuestionAnswers = ContextGateway <QuestionAnswers> .List(e => e.QuestionId == id); return(this.Map(questions)); }
public List <DifficultyLevelsDataModel> list() { //List<DifficultyLevelsDataModel> listOfDifficultyLevels = DifficultyLevelsRepositoryGateWay.List().Select // (s=>new DifficultyLevelsDataModel { Id = s.Id, DifficultyLevelName = s.DifficultyLevelName }).ToList(); // return listOfDifficultyLevels; List <DifficultyLevelsDataModel> listOfDifficultyLevels = ContextGateway <DifficultyLevels> .List().Select (s => new DifficultyLevelsDataModel { Id = s.Id, DifficultyLevelName = s.DifficultyLevelName }).ToList(); return(listOfDifficultyLevels); // return null; }
public List <QuestionsDataModel> list() { //repositoryGateWay = new RepositoryGateWay<Questions>(); //RepositoryGateWay<QuestionAnswers> QuestionAnswersRepositoryGateWay = new RepositoryGateWay<QuestionAnswers>(); ContextGateway <Questions> .GetContextInstance(); return(ContextGateway <Questions> .List(l => l.Id == l.Id, i => i.QuestionAnswers).Select (s => new QuestionsDataModel { Id = s.Id, QuestionText = s.QuestionText, QuestionAnswersDataModel = (from qa in s.QuestionAnswers select new QuestionAnswersDataModel { QuestionId = qa.QuestionId, AnswerText = qa.AnswerText, IsCorrext = qa.IsCorrect, Id = qa.Id }).ToList() }).ToList()); }
public DifficultyLevelsOperations() { ContextGateway <DifficultyLevels> .GetContextInstance(); }