public async Task <IEnumerable <ServiceEntities.Question> > GetQuestions()
        {
            var questions = await _questionRepo.FindByAsync(x => x.Id > -1).ConfigureAwait(false);

            var questionsList = questions.ToList();

            return(questionsList.Select(_questionMapper.ToServiceEntity));
        }
示例#2
0
        public async Task QuestionCreateCommandTriggersEventToUpdateQueryDbWithQuestion()
        {
            var questionText = "Test Question 1";

            //Arrange
            var command = new QuestionCreateCommand(questionText);
            await _commandBus.Send(command);

            //Act
            var questions = await _questionRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false);

            var question = questions.FirstOrDefault();

            //Act
            Assert.IsNotNull(question);
            Assert.AreEqual(questionText, question.Text);
        }
        public async Task Handle(QuestionDeletedEvent handle)
        {
            var items = await _questionRepo.FindByAsync(c => c.Id == handle.AggregateId).ConfigureAwait(false);

            var item = items.FirstOrDefault();

            if (item != null)
            {
                await _questionRepo.Delete(item).ConfigureAwait(false);
            }
        }
        public async Task Handle(QuestionTextChangedEvent handle)
        {
            var items = await _questionRepo.FindByAsync(c => c.Id == handle.AggregateId).ConfigureAwait(false);

            var item = items.FirstOrDefault();

            if (item != null)
            {
                item.Text         = handle.Question;
                item.Version      = handle.Version;
                item.ModifiedDate = handle.Timestamp;
            }

            await _questionRepo.Update(item);
        }