diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/DataRemoveModel.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/DataRemoveModel.kt index 2f9c8fd9..49b57999 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/DataRemoveModel.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/DataRemoveModel.kt @@ -38,12 +38,12 @@ open class DataRemoveModel { fun commit(profileId: Int, dao: GradeDao) { if (all) { - if (type != null) dao.clearWithType(profileId, type) + if (type != null) dao.dontKeepWithType(profileId, type) else dao.clear(profileId) } semester?.let { - if (type != null) dao.clearForSemesterWithType(profileId, it, type) - else dao.clearForSemester(profileId, it) + if (type != null) dao.dontKeepForSemesterWithType(profileId, it, type) + else dao.dontKeepForSemester(profileId, it) } } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/GradeDao.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/GradeDao.kt index 5862859e..4fcfc721 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/GradeDao.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/GradeDao.kt @@ -82,14 +82,14 @@ abstract class GradeDao : BaseDao { fun getByIdNow(profileId: Int, id: Long) = getOneNow("$QUERY WHERE grades.profileId = $profileId AND gradeId = $id") - @Query("DELETE FROM grades WHERE profileId = :profileId AND gradeType = :type") - abstract fun clearWithType(profileId: Int, type: Int) + @Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeType = :type") + abstract fun dontKeepWithType(profileId: Int, type: Int) - @Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester") - abstract fun clearForSemester(profileId: Int, semester: Int) + @Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester") + abstract fun dontKeepForSemester(profileId: Int, semester: Int) - @Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type") - abstract fun clearForSemesterWithType(profileId: Int, semester: Int, type: Int) + @Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type") + abstract fun dontKeepForSemesterWithType(profileId: Int, semester: Int, type: Int)