package com.yono.messeripos.repositories;

import android.app.Application;

import androidx.lifecycle.LiveData;

import com.yono.messeripos.daos.PaymentPendingDaos;
import com.yono.messeripos.database.LocalDatabase;
import com.yono.messeripos.models.PaymentPending;
import com.yono.messeripos.models.ProductCartModels;

import java.util.List;

public class PaymentPendingRepositories {
    private PaymentPendingDaos daos;
    private LiveData<List<PaymentPending>> paymentPending;
    public PaymentPendingRepositories(Application application) {
        LocalDatabase db = LocalDatabase.geDatabase(application);
        daos = db.paymentPendingDaos();

        paymentPending = daos.getAll();
    }

    public LiveData<List<PaymentPending>> getPaymentPending(){
        return paymentPending;
    }

    public void insert(PaymentPending paymentPending){
        LocalDatabase.databaseWriterExecutor.execute(() -> daos.insertPaymentPending(paymentPending));
    }

//    public void delete(ProductCartModels productCartModels){
//        LocalDatabase.databaseWriterExecutor.execute(() -> daos.del(productCartModels));
//    }

    public void updateIdNfc(String idNfc, long id){
        LocalDatabase.databaseWriterExecutor.execute(() ->daos.updateNfc(idNfc, id));
    }

    public LiveData<List<PaymentPending>> getPaymentByOrderId(String idOrders){
        return daos.getPaymentByIdOrder(idOrders);
    }
}
