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.StockTakeEntity;


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

@Dao
public interface StockTakeDao {

    @Query("SELECT * FROM stockTake")
    List<StockTakeEntity> loadAllStockTakes();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<StockTakeEntity> stockTakeEntityList);


    @Query("select * from stockTake where id = :id ORDER BY id DESC LIMIT 1")
    List<StockTakeEntity> getStockTake(String id);

    @Query("select * from stockTake where sendStatus = 0 ORDER BY id")
    List<StockTakeEntity> getAllUnsentStockTake();

    @Query("select * from stockTake where sendStatus = 1 ORDER BY id")
    List<StockTakeEntity> getAllSentStockTake();

    @Query("DELETE from stockTake where sendStatus = 0")
    void deleteAllUnsentStockTake();

    @Query("DELETE from stockTake where sendStatus = 1")
    void deleteAllSentStockTake();

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

    @Insert
    long insert(StockTakeEntity stockTakeEntity);

    @Update
    void update(StockTakeEntity stockTakeEntity);

    @Delete
    void delete(StockTakeEntity stockTakeEntity);
}
