Ejemplo n.º 1
0
        public async Task <IDictionary <string, IReadOnlyCollection <Sentence> > > GetUserUpdate(IPrincipal user, IDictionary <string, string> monikers = null)
        {
            monikers = monikers ?? new Dictionary <string, string>();

            var userAccount = await _userService.FindById(user.UserId());

            var channelIds = userAccount.Channels;

            if (!channelIds.Contains("global"))
            {
                channelIds.Add("global");
            }

            foreach (var channelId in channelIds)
            {
                if (monikers.ContainsKey(channelId))
                {
                    continue;
                }

                monikers.Add(channelId, null);
            }

            var queries = monikers.Keys
                          .Select(channelId => new SentencesViaChannel(channelId, monikers[channelId]))
                          .ToArray();

            await _client.Find(queries);

            return(queries.ToDictionary(m => m.Channelid, m => m.Sentences ?? new List <Sentence>()));
        }