public async Task SaveMessageToAllMessages(ChatMqMessage messagefromMq)
        {
            var database = await RetrieveOrCreateDatabaseAsync();

            var collection = await RetrieveOrCreateCollectionAsync(database.SelfLink, "messages");

            var message = new MessageDbSchema()
            {
                Message   = messagefromMq.Message,
                Recepient = messagefromMq.To,
                Sender    = messagefromMq.From,
                Time      = DateTime.Now,
                IsRead    = true
            };

            await _client.UpsertDocumentAsync(collection.DocumentsLink, message);
        }
        public async Task SaveMessageToLastMessages(ChatMqMessage message)
        {
            var database = await RetrieveOrCreateDatabaseAsync();

            var collection = await RetrieveOrCreateCollectionAsync(database.SelfLink, "lastmessages");

            var lastMessage = new LastMessageDocumentDbSchema()
            {
                LastMessage = message.Message,
                Recepient   = message.To,
                Sender      = message.From,
                Time        = DateTime.Now, IsRead = true
            };

            try
            {
                await _client.UpsertDocumentAsync(collection.DocumentsLink, lastMessage);
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 3
0
        public Task SendMessageToQueue(ChatMqMessage mqMessage)
        {
            var message = new BrokeredMessage(JsonConvert.SerializeObject(mqMessage));

            return(_queueClient.SendAsync(message));
        }