示例#1
0
        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);
        }
示例#2
0
        public List <Pregunta> GetDeviceQuestions(string deviceName)
        {
            QuizDeviceModel      device        = _quizDeviceRepository.GetByName(deviceName);
            List <QuestionModel> questionModel = _questionRepository.GetByQuizId(device.QuizToApplyId).ToList();

            List <Pregunta> lstPreguntas = new List <Pregunta>();

            foreach (QuestionModel model in questionModel)
            {
                lstPreguntas.Add(new Pregunta(model.QuestionId, model.Question));
            }

            if (lstPreguntas.Count() == 0)
            {
                throw new Exception("Dispositivo mal configurado, no tiene ninguna encuesta vinculada.");
            }

            return(lstPreguntas);
        }