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

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

@Dao
public interface FacingDao {

    @Query("SELECT * FROM facing")
    List<FacingEntity> loadAllFacings();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<FacingEntity> facingEntityList);


    @Query("select * from facing where id = :id ORDER BY id DESC LIMIT 1")
    List<FacingEntity> getFacing(String id);

    @Query("select * from facing where sendStatus = 0 ORDER BY id")
    List<FacingEntity> getAllUnsentFacing();

    @Query("select * from facing where sendStatus = 1 ORDER BY id")
    List<FacingEntity> getAllSentFacing();

    @Query("DELETE from facing where sendStatus = 0")
    void deleteAllUnsentFacing();

    @Query("DELETE from facing where sendStatus = 1")
    void deleteAllSentFacing();

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

    @Insert
    long insert(FacingEntity facingEntity);

    @Update
    void update(FacingEntity facingEntity);

    @Delete
    void delete(FacingEntity facingEntity);
}
