package com.example.shawarma.data.repos

import com.example.shawarma.data.interfaces.dao.OrderDao
import com.example.shawarma.data.models.OrderModel
import com.example.shawarma.data.models.OrderWithProducts
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class OrderRepository @Inject constructor(
    private val orderDao: OrderDao
){
    suspend fun insert(order: OrderModel): Long {
        return orderDao.insert(order)
    }
    suspend fun update(order:OrderModel) {
        return orderDao.update(order)
    }
    suspend fun delete(order: OrderModel) {
        return orderDao.delete(order)
    }
    fun getAll(): Flow<List<OrderWithProducts>> {
        return orderDao.getAll()
    }
    fun getById(id: Int): Flow<List<OrderWithProducts>> {
        return orderDao.getById(id)
    }
    fun getByUserId(userId: Int): Flow<List<OrderWithProducts>> {
        return orderDao.getByUserId(userId)
    }
    fun getUnpaidByUser(userId: Int) : Flow<OrderWithProducts?> {
        return orderDao.getUnpaidByUser(userId)
    }
    fun getPaidByUser(userId: Int) : Flow<List<OrderWithProducts>> {
        return orderDao.getPaidByUser(userId)
    }
}