package in.techware.carrefour.dbUtils.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import java.util.List;

import in.techware.carrefour.dbUtils.entity.OutOfStockEntity;


/**
 * Created by Jemsheer K D on 25 July, 2018.
 * Package in.techware.carrefour.dbUtils.dao
 * Project Carrefour
 */

@Dao
public interface OutOfStockDao {

    @Query("SELECT * FROM outOfStock")
    List<OutOfStockEntity> loadAllOutOfStocks();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<OutOfStockEntity> outOfStockEntityList);


    @Query("select * from outOfStock where id = :id ORDER BY id DESC LIMIT 1")
    List<OutOfStockEntity> getOutOfStock(String id);

    @Query("select * from outOfStock where sendStatus = 0 ORDER BY id")
    List<OutOfStockEntity> getAllUnsentOutOfStock();

    @Query("select * from outOfStock where sendStatus = 1 ORDER BY id")
    List<OutOfStockEntity> getAllSentOutOfStock();

    @Query("DELETE from outOfStock where sendStatus = 0")
    void deleteAllUnsentOutOfStock();

    @Query("DELETE from outOfStock where sendStatus = 1")
    void deleteAllSentOutOfStock();

    @Query("DELETE FROM outOfStock")
    void deleteAll();

    @Insert
    long insert(OutOfStockEntity outOfStockEntity);

    @Update
    void update(OutOfStockEntity outOfStockEntity);

    @Delete
    void delete(OutOfStockEntity outOfStockEntity);
}
