package com.example.myapplication.database.repository

import com.example.myapplication.database.dao.UserDao
import com.example.myapplication.database.entities.User
import com.example.myapplication.database.entities.UserProductCart
import com.example.myapplication.database.entities.UserWithCartProduct
import kotlinx.coroutines.flow.Flow

class OfflineUserRepository(private val userDao: UserDao) : UserRepository {
    override suspend fun getAll(): List<User> = userDao.getAll()
    override suspend fun getById(id: Int): User = userDao.getById(id)
    override suspend fun getByAuth(login: String, password: String): User? = userDao.getByAuth(login, password)
    override suspend fun getUserProductCartById(id: Int): UserWithCartProduct = userDao.getUserProductCartById(id)

    override suspend fun deleteCartProduct(userId: Int, productId: Int) = userDao.deleteCartProduct(userId, productId)

    override suspend fun insert(user: User) = userDao.insert(user)
    override suspend fun addProductCart(userProduct: UserProductCart) = userDao.addProductCart(userProduct)
}