Beispiel #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));
        }