This commit is contained in:
Milos Kozak 2023-05-13 19:36:09 +02:00
parent 129869b720
commit 016cf9dada

View file

@ -8,7 +8,7 @@ class InsertOrUpdateHeartRateTransaction(private val heartRate: HeartRate):
override fun run(): TransactionResult { override fun run(): TransactionResult {
val existing = if (heartRate.id == 0L) null else database.heartRateDao.findById(heartRate.id) val existing = if (heartRate.id == 0L) null else database.heartRateDao.findById(heartRate.id)
return if (existing == null) { return if (existing == null) {
database.heartRateDao.insertNewEntry(heartRate).let { id -> database.heartRateDao.insertNewEntry(heartRate).let {
TransactionResult(listOf(heartRate), emptyList()) } TransactionResult(listOf(heartRate), emptyList()) }
} else { } else {
database.heartRateDao.updateExistingEntry(heartRate) database.heartRateDao.updateExistingEntry(heartRate)