Example #1
0
        public async Task <IDictionary <Guid, string> > HandleAsync(GetAllUserQuestionsQuery query)
        {
            var streamId    = $"{StreamPrefix.Question}_{query.User}";
            var aggregation = await _connectionProvider.Dispatch <AllQuestionByUserProjection, QuestionTeasersWith100CharactersState>(streamId).ConfigureAwait(false);

            if (!aggregation.Any())
            {
                return(new Dictionary <Guid, string>());
            }
            return(aggregation.ToDictionary((k) => new Guid(k.Key), (v) => v.Value.Questions));
        }
        public async Task <IDictionary <Guid, string> > HandleAsync(GetAllTagsQuery query)
        {
            var streamId    = $"{StreamPrefix.Question}_{query.User}";
            var aggregation = await _connectionProvider.Dispatch <GetAllTagsProjection, TagNameState>(streamId).ConfigureAwait(false);

            if (!aggregation.Any())
            {
                return(new Dictionary <Guid, string>());
            }

            return(aggregation.Select(kv => new KeyValuePair <Guid, string>(Guid.Parse(kv.Key), kv.Value.Name)).ToDictionary(pair => pair.Key, pair => pair.Value));
        }
Example #3
0
        public async Task <QuestionWithAnswersState> HandleAsync(GetQuestionWithAnswersQuery query)
        {
            var streamId    = $"{StreamPrefix.Question}_{query.User}";
            var aggregation = await _connectionProvider.Dispatch <QuestionWithAnswerProjection, QuestionWithAnswersState>(streamId).ConfigureAwait(false);

            if (!aggregation.Any())
            {
                return(new QuestionWithAnswersState());
            }

            return(aggregation.Single(e => e.Key == query.QuestionId.ToString()).Value);
        }