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


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

@Dao
public interface LabelSurveyDao {

    @Query("SELECT * FROM labelSurvey")
    List<LabelSurveyEntity> loadAllLabelSurveys();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<LabelSurveyEntity> labelSurveyEntityList);


    @Query("select * from labelSurvey where id = :id ORDER BY id DESC LIMIT 1")
    List<LabelSurveyEntity> getLabelSurvey(String id);

    @Query("select * from labelSurvey where sendStatus = 0 ORDER BY id")
    List<LabelSurveyEntity> getAllUnsentLabelSurvey();

    @Query("select * from labelSurvey where sendStatus = 1 ORDER BY id")
    List<LabelSurveyEntity> getAllSentLabelSurvey();

    @Query("DELETE from labelSurvey where sendStatus = 0")
    void deleteAllUnsentLabelSurvey();

    @Query("DELETE from labelSurvey where sendStatus = 1")
    void deleteAllSentLabelSurvey();

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

    @Insert
    long insert(LabelSurveyEntity labelSurveyEntity);

    @Update
    void update(LabelSurveyEntity labelSurveyEntity);

    @Delete
    void delete(LabelSurveyEntity labelSurveyEntity);
}
