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()); }