package com.example.timert.data.repository

import androidx.lifecycle.LiveData
import com.example.timert.data.dao.TrainingDao
import com.example.timert.data.entity.Training
import com.example.timert.data.trainingWithExercise

class TrainingRepository(private val trainingDao: TrainingDao) {

    val allTrainings: LiveData<List<Training>> = trainingDao.getAllTrainings()
    val allTrainingsWithExercises: LiveData<List<trainingWithExercise>> = trainingDao.getTrainingsWithExercises()

    suspend fun insert(training: Training): Long {
        return trainingDao.insertTraining(training)
    }

    suspend fun delete(training: Training) = trainingDao.deleteTraining(training)

    suspend fun deleteTrainingById(id: Int) {
        trainingDao.deleteById(id)
    }

    fun getTrainingById(id: Int): LiveData<Training> {
        return trainingDao.getTrainingById(id)
    }

}