public QuizDto GetQuiz(int quizId = 0) { if (quizId == 0) { return new QuizDto() { Questions = new ObservableCollection <QuestionDto>() } } ; QuizDto quizDto = new QuizDto(); quizDto.Questions = new ObservableCollection <QuestionDto>(); QuizModel quizModel = quizRepository.Get(quizId); quizDto.QuizId = quizModel.QuizId; quizDto.Name = quizModel.QuizName; List <QuestionModel> questionList = questionRepository.GetByQuizId(quizId).ToList(); foreach (QuestionModel questionModel in questionList) { quizDto.Questions.Add(new QuestionDto() { QuestionId = questionModel.QuestionId, Question = questionModel.Question }); } return(quizDto); }
public FlagQuizController() { var quizRepository = new QuizRepository(); _flagRepository = new FlagRepository(); _game = quizRepository.Get(1); }
public List <QuizDeviceDto> GetQuizDeviceList() { try { return(_quizDeviceRepository.GetAll() .Select(x => new QuizDeviceDto() { QuizDeviceId = x.QuizDeviceId, QuizToApplyId = x.QuizToApplyId, QuizName = _quizRepository.Get(x.QuizToApplyId).QuizName, QuizDeviceLocation = x.QuizDeviceLocation, QuizDeviceName = x.QuizDeviceName }).ToList()); } catch (Exception ex) { return(new List <QuizDeviceDto>()); } }