Exemplo n.º 1
0
        public async Task <IHttpActionResult> SendMessage(MessageAddViewModel message)
        {
            var conversationResult = _conversationService.GetById(message.ConversationId);

            if (conversationResult.IsError)
            {
                return(NotFound());
            }

            var conversation = conversationResult.Value;

            var fbMesageResult = await _facebbokMessageService.SendMessageToConversation(conversation.FacebookConversationId, message.Content);

            if (fbMesageResult.IsError)
            {
                return(InternalServerError());
            }

            var fbMessage = fbMesageResult.Value;

            var addedMessage = _messageService.AddMessageToConversation(message.ConversationId,
                                                                        message.Content, fbMessage.Id, base.UserId);

            if (addedMessage.IsError)
            {
                return(InternalServerError());
            }

            return(Ok(addedMessage.Value));
        }
Exemplo n.º 2
0
        private async Task SendMessage(Models.Conversation.ConversationModel conversation, string message)
        {
            var fbMesageResult = await _facebbokMessageService.SendMessageToConversation(conversation.FacebookConversationId, message);

            if (fbMesageResult.IsError)
            {
                return;
            }

            var fbMessage = fbMesageResult.Value;

            _messageService.AddMessageToConversation(conversation.Id,
                                                     message, fbMessage.Id);
        }