Exemple #1
0
        public void BatchUpdateUnreadCounters(string business_id)
        {
            Dictionary <string, Counter> channelCounters = GetChannelCounters(business_id).Result.Where(c => !string.IsNullOrWhiteSpace(c.id)).ToDictionary(c => c.id, c => c);
            Dictionary <string, Counter> agentCounters   = GetAgentCounters(business_id).Result.Where(a => !string.IsNullOrWhiteSpace(a.id)).ToDictionary(c => c.id, c => c);

            foreach (var a in _agentService.GetAgents(business_id, 0, 100).Result)

            {
                int count = agentCounters.ContainsKey(a.id) ? agentCounters[a.id].unread : 0;
                _counterService.SetAgentUnreadThreadsCount(business_id, a.id, count);
            }
            foreach (var c in _channelService.GetChannels(business_id, 0, 50).Result)
            {
                int count = channelCounters.ContainsKey(c.id) ? channelCounters[c.id].unread : 0;
                _counterService.SetChannelUnreadThreadsCount(business_id, c.id, count);
            }
        }