public void DeleteSingleUnreadThreadFromAgent(string business_id, string agent_id, string thread_id) { try { _counterRepository.DeleteThreadFromAgentsUnread(business_id, agent_id, thread_id); } catch { } }
public bool SendMessageToThreadWithCountersUpdate(string business_id, Message message, Thread thread) { message.thread_id = thread.id; _messageRepository.Upsert(message); BackgroundJob.Enqueue <MessageService>(x => x.CopyMessageToRealtimeDB(business_id, message.id, message.timestamp)); var counter = new Counter { id = thread.id, count = 1 }; _counterRepository.AddThreadToChannels(business_id, message.channel_id, counter); if (!string.IsNullOrWhiteSpace(thread.agent_id)) { _counterRepository.AddThreadToAgents(business_id, thread.agent_id, counter); } if (thread.unread) { _counterRepository.AddThreadToChannelsUnread(business_id, message.channel_id, counter); if (string.IsNullOrWhiteSpace(thread.agent_id)) { _counterRepository.AddThreadToChannelsUnassignedUnread(business_id, message.channel_id, counter); } else { _counterRepository.AddTheadToAgentsUnread(business_id, thread.agent_id, counter); } } else { try { _counterRepository.DeleteThreadFromChannelsUnread(business_id, message.channel_id, counter.id); } catch { } if (string.IsNullOrWhiteSpace(thread.agent_id)) { try { _counterRepository.DeleteThreadFromChannelsUnassignedUnread(business_id, message.channel_id, counter.id); } catch { } } else { try { _counterRepository.DeleteThreadFromAgentsUnread(business_id, thread.agent_id, counter.id); } catch { } } } return(true); }
public bool SendMessageToThreadWithCountersUpdate(string business_id, MessageModel message, Thread thread) { //_messageRepository.Add(message); _messageRepository.Upsert(business_id, message); _messageRepository.AddGroupedByThread(business_id, message, thread.id); var counter = new Counter { id = thread.id, count = 1 }; _counterRepository.AddThreadToChannels(business_id, message.channel_id, counter); if (!string.IsNullOrWhiteSpace(thread.agent_id)) { _counterRepository.AddThreadToAgents(business_id, thread.agent_id, counter); } if (thread.unread) { _counterRepository.AddThreadToChannelsUnread(business_id, message.channel_id, counter); if (string.IsNullOrWhiteSpace(thread.agent_id)) { _counterRepository.AddThreadToChannelsUnassignedUnread(business_id, message.channel_id, counter); } else { _counterRepository.AddTheadToAgentsUnread(business_id, thread.agent_id, counter); } } else { try { _counterRepository.DeleteThreadFromChannelsUnread(business_id, message.channel_id, counter.id); } catch { } if (string.IsNullOrWhiteSpace(thread.agent_id)) { try { _counterRepository.DeleteThreadFromChannelsUnassignedUnread(business_id, message.channel_id, counter.id); } catch { } } else { try { _counterRepository.DeleteThreadFromAgentsUnread(business_id, thread.agent_id, counter.id); } catch { } } } return(true); }
public Thread UnAssignFromAgent(string business_id, string thread_id) { var thread = GetById(business_id, thread_id); if (thread == null) { return(thread); } string agent_id = thread.agent_id; business_id = thread.business_id; thread.agent_id = ""; thread.status = "pending"; CreateThread(thread, true); if (string.IsNullOrWhiteSpace(agent_id)) { return(thread); } //update counters var counter = new Counter { id = thread_id, count = 1 }; try { _counterRepository.DeleteThreadFromAgentsAll(business_id, agent_id, thread_id); } catch { } try { _counterRepository.DeleteThreadFromAgentsUnread(business_id, agent_id, thread_id); } catch { } return(thread); }