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


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

@Dao
public interface InternalSalesCorrectionDao {

    @Query("SELECT * FROM internalSalesCorrection")
    List<InternalSalesCorrectionEntity> loadAllInternalSalesCorrections();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<InternalSalesCorrectionEntity> internalSalesCorrectionEntityList);


    @Query("select * from internalSalesCorrection where id = :id ORDER BY id DESC LIMIT 1")
    List<InternalSalesCorrectionEntity> getInternalSalesCorrection(String id);

    @Query("select * from internalSalesCorrection where sendStatus = 0 ORDER BY id")
    List<InternalSalesCorrectionEntity> getAllUnsentInternalSalesCorrection();

    @Query("select * from internalSalesCorrection where sendStatus = 1 ORDER BY id")
    List<InternalSalesCorrectionEntity> getAllSentInternalSalesCorrection();

    @Query("DELETE from internalSalesCorrection where sendStatus = 0")
    void deleteAllUnsentInternalSalesCorrection();

    @Query("DELETE from internalSalesCorrection where sendStatus = 1")
    void deleteAllSentInternalSalesCorrection();

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

    @Insert
    long insert(InternalSalesCorrectionEntity internalSalesCorrectionEntity);

    @Update
    void update(InternalSalesCorrectionEntity internalSalesCorrectionEntity);

    @Delete
    void delete(InternalSalesCorrectionEntity internalSalesCorrectionEntity);
}
