package com.example.ayudapy import android.os.AsyncTask import androidx.annotation.WorkerThread import androidx.lifecycle.LiveData // Declares the DAO as a private property in the constructor. Pass in the DAO // instead of the whole database, because you only need access to the DAO class PedidoRepository(private val pedidoDao: DaoPedido) { val allPedidos: LiveData> = pedidoDao.getAll() @WorkerThread fun insert(word: PedidoSave) { pedidoDao.insert(word) } @WorkerThread fun delete(word: PedidoSave) { pedidoDao.delete(word) } /* --------------- BORRAR TODOS LOS DATOS -------------- */ /*fun deleteAll() { deleteAllWordsAsyncTask(wordDao).execute() }*/ /* private class deleteAllWordsAsyncTask internal constructor(private val mAsyncTaskDao: DaoPedido) : AsyncTask() { override fun doInBackground(vararg voids: Void): Void? { mAsyncTaskDao.delete() return null } }*/ /* ---------------- BORRAR UN SOLO DATO ---------------- */ /* fun deleteWord(word: PedidoSave) { deleteWordAsyncTask(wordDao).execute(word) } private class deleteWordAsyncTask internal constructor(private val mAsyncTaskDao: DaoPedido) : AsyncTask() { override fun doInBackground(vararg params: PedidoSave): Void? { mAsyncTaskDao.delete(params[0]) return null } }*/ /* -------------- ACTUALIZAR UN SOLO DATO ---------------- fun update(word: Word) { updateWordAsyncTask(wordDao).execute(word) } private class updateWordAsyncTask internal constructor(private val mAsyncTaskDao: WordDao) : AsyncTask() { override fun doInBackground(vararg params: Word?): Void? { mAsyncTaskDao.update(params[0]!!) return null } }*/ }