Esempio n. 1
0
        public HttpResponseMessage GetConversationsBySenderId(string senderId)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ConversationListDomain conversationList = _ConversationService.GetConversationsBySenderId(senderId);

            var response = new ItemResponse <ConversationListDomain> {
                Item = conversationList
            };

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        public ConversationListDomain GetConversationsBySenderId(string sender_id)
        {
            ConversationListDomain conversationList = null;

            try
            {
                conversationList = new ConversationListDomain();

                conversationList.BotConversation = BotConversationService.BuildBotProfile();

                conversationList.UnreadConversations = GetUnreadConversationIdByUserId(sender_id);

                conversationList.ConversationObjects = GetDBConversationsBySenderId(sender_id);

                if (conversationList.ConversationObjects != null && conversationList.ConversationObjects.Count > 0)
                {
                    foreach (ConversationDomain convo in conversationList.ConversationObjects)
                    {
                        convo.IsRead = true;

                        for (int i = 0; i < conversationList.UnreadConversations.Count; i++)
                        {
                            if (convo.ConversationId == conversationList.UnreadConversations[i])
                            {
                                convo.IsRead = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(conversationList);
        }