Пример #1
0
        public async Task AddQuestionAsync(Question question, string[] answers)
        {
            var questions = await _questionsRepository.GetAllAsync();

            question.Order = questions.Length == 0
                ? 0
                : questions.Length;
            string questionId = await _questionsRepository.AddAsync(question);

            await _answersRepository.AddAnswersAsync(answers.Select((x, i) => new Answer {
                QuestionId = questionId, Text = x, Order = i
            }));
        }