예제 #1
0
        public async Task <int> Update(Converse.Models.ChatMessage message)
        {
            var chatMessage = Database.Models.ChatMessage.FromChatMessage(message);

            if (chatMessage == null)
            {
                return(-1);
            }
            var dbEntry = await _database.FindAsync <Database.Models.ChatMessage>(c => c.ChatID == chatMessage.ChatID && c.MessageID == chatMessage.MessageID);

            if (dbEntry == null)
            {
                try
                {
                    return(await _database.InsertAsync(chatMessage));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    return(0);
                }
            }

            chatMessage.ID = dbEntry.ID;
            return(await _database.UpdateAsync(chatMessage));
        }
예제 #2
0
        public async Task <int> Insert(Converse.Models.ChatMessage message)
        {
            var p = Models.ChatMessage.FromChatMessage(message);

            if (p == null)
            {
                return(-1);
            }
            var insertedRows = await _database.InsertAsync(p);

            return(insertedRows == 1 ? p.ID : -1);
        }