public async Task <int> Insert(int chatID, int lastReadMessageID) { var p = new LastReadMessageID { ChatID = chatID, LastReadID = lastReadMessageID }; var insertedRows = await _database.InsertAsync(p); return(insertedRows == 1 ? p.ID : -1); }
public async Task <int> Update(int chatID, int lastReadMessageID) { var p = new LastReadMessageID { ChatID = chatID, LastReadID = lastReadMessageID }; var dbEntry = await _database.FindAsync <LastReadMessageID>(c => c.ChatID == p.ChatID); if (dbEntry == null) { try { return(await _database.InsertAsync(p)); } catch (Exception ex) { Debug.WriteLine(ex); return(0); } } p.ID = dbEntry.ID; return(await _database.UpdateAsync(p)); }