package com.example.pap_teste.data;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import com.example.pap_teste.models.LocalReservation;
import java.util.List;

@Dao
public interface ReservationDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(LocalReservation reservation);

    @Update
    void update(LocalReservation reservation);

    @Delete
    void delete(LocalReservation reservation);

    @Query("SELECT * FROM local_reservations ORDER BY date DESC, time DESC")
    LiveData<List<LocalReservation>> getAllReservations();

    @Query("SELECT * FROM local_reservations WHERE date = :date AND tableNumber = :tableId AND status != 'CANCELLED'")
    List<LocalReservation> getReservationsForTable(String date, int tableId);
}
