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


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

@Dao
public interface PromotionDao {

    @Query("SELECT * FROM promotion")
    List<PromotionEntity> loadAllPromotions();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<PromotionEntity> promotionEntityList);


    @Query("select * from promotion where id = :id ORDER BY id DESC LIMIT 1")
    List<PromotionEntity> getPromotion(String id);

    @Query("select * from promotion where sendStatus = 0 ORDER BY id")
    List<PromotionEntity> getAllUnsentPromotion();

    @Query("select * from promotion where sendStatus = 1 ORDER BY id")
    List<PromotionEntity> getAllSentPromotion();

    @Query("DELETE from promotion where sendStatus = 0")
    void deleteAllUnsentPromotion();

    @Query("DELETE from promotion where sendStatus = 1")
    void deleteAllSentPromotion();

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

    @Insert
    long insert(PromotionEntity promotionEntity);

    @Update
    void update(PromotionEntity promotionEntity);

    @Delete
    void delete(PromotionEntity promotionEntity);
}
