package cz.muni.sutralog.repository

import cz.muni.sutralog.data.CategoryPresentableListItem
import cz.muni.sutralog.data.PhotoPresentableListItem
import cz.muni.sutralog.data.RockPresentableListItem
import cz.muni.sutralog.database.CategoryEntity
import cz.muni.sutralog.database.PhotoEntity
import cz.muni.sutralog.database.RockEntity

fun RockPresentableListItem.toRockEntity(): RockEntity =
    RockEntity(
        categoryId = this.categoryId,
        where = this.where,
        locality = this.locality,
        longitude = this.longitude,
        latitude = this.latitude,
        from = this.from,
        description = this.description,
        date = date,
        count = this.count,
        comment = this.comment,
        id = this.id,
        color = this.color,
        name = this.name,
    )

fun RockEntity.toPresentableRockItem(): RockPresentableListItem =
    RockPresentableListItem(
        categoryId = this.categoryId,
        where = this.where,
        locality = this.locality,
        longitude = this.longitude,
        latitude = this.latitude,
        from = this.from,
        description = this.description,
        date = date,
        count = this.count,
        comment = this.comment,
        id = this.id,
        color = this.color,
        name = this.name,
    )

fun PhotoEntity.toPresentablePhotoItem(): PhotoPresentableListItem =
    PhotoPresentableListItem(
        id = this.id,
        rockId = this.rockId,
        path = this.path
    )

fun PhotoPresentableListItem.toPhotoEntity(): PhotoEntity =
    PhotoEntity(
        id = this.id,
        rockId = this.rockId,
        path = this.path,
    )


fun CategoryPresentableListItem.toCategoryEntity(): CategoryEntity =
    CategoryEntity(
        id = this.id,
        name = this.name,
        color = this.color,
    )

fun CategoryEntity.toPresentableCategoryItem(): CategoryPresentableListItem =
    CategoryPresentableListItem(
        id = this.id,
        name = this.name,
        color = this.color,
    )