Exemplo n.º 1
0
        // PUBLIC
        // =============================================================================================
        public TestQuestionDTO UpsertQuestion(TestQuestionDTO questionReceived)
        {
            var           id = questionReceived.id;
            test_question question;

            if (id == 0)
            {
                question = new test_question();
                TestQuestionMapper.CopyValues(questionReceived, question);
                _questionRepository.Add(question);
            }
            else
            {
                question = _questionRepository.Get(id);
                _questionRepository.SetNewValues(questionReceived, question);
            }

            return(TestQuestionMapper.GetDTO(question));
        }
Exemplo n.º 2
0
        public IEnumerable <TestQuestionDto> GetQuestionsByTestId(int testId)
        {
            IEnumerable <TestQuestion> testQuestions = testQuestionRepository.Get(filter: q => q.TestId == testId);

            return(mapper.Map <IEnumerable <TestQuestionDto> >(testQuestions));
        }