diff --git a/app/src/main/java/com/example/flowershopapp/API/Model/BouquetRemote.kt b/app/src/main/java/com/example/flowershopapp/API/Model/BouquetRemote.kt index fd0af66..87a4aac 100644 --- a/app/src/main/java/com/example/flowershopapp/API/Model/BouquetRemote.kt +++ b/app/src/main/java/com/example/flowershopapp/API/Model/BouquetRemote.kt @@ -6,7 +6,7 @@ import java.util.Base64 @Serializable data class BouquetRemote( - val id: Int? = 0, + val id: Int? = null, val name: String = "", val quantityOfFlowers: Int = 0, val price: Int = 0, @@ -22,7 +22,7 @@ fun BouquetRemote.toBouquet(): Bouquet = Bouquet( ) fun Bouquet.toBouquetRemote(): BouquetRemote = BouquetRemote( - bouquetId, + null, name, quantityOfFlowers, price, diff --git a/app/src/main/java/com/example/flowershopapp/API/Model/OrderBouquetRemote.kt b/app/src/main/java/com/example/flowershopapp/API/Model/OrderBouquetRemote.kt deleted file mode 100644 index 7ab2a02..0000000 --- a/app/src/main/java/com/example/flowershopapp/API/Model/OrderBouquetRemote.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.flowershopapp.API.Model - -import com.example.flowershopapp.Entities.Model.OrdersWithBouquets -import kotlinx.serialization.Serializable - -@Serializable -data class OrderBouquetRemote( - val order: OrderRemote = OrderRemote(), - val bouquet: List = listOf() -) - -fun OrderBouquetRemote.toOrdersWithBouquets(): OrdersWithBouquets { - val convertedOrder = this.order.toOrder() - val convertedBouquets = this.bouquet.map { it.toBouquet() } - return OrdersWithBouquets(convertedOrder, convertedBouquets) -} - -fun OrdersWithBouquets.toOrderBouquetRemote(): OrderBouquetRemote { - val convertedOrder = this.order.toOrderRemote() - val convertedBouquets = this.bouquets.map { it.toBouquetRemote() } - return OrderBouquetRemote(convertedOrder, convertedBouquets) -} \ No newline at end of file diff --git a/app/src/main/java/com/example/flowershopapp/API/Model/OrderRemote.kt b/app/src/main/java/com/example/flowershopapp/API/Model/OrderRemote.kt index d988b60..2fc5829 100644 --- a/app/src/main/java/com/example/flowershopapp/API/Model/OrderRemote.kt +++ b/app/src/main/java/com/example/flowershopapp/API/Model/OrderRemote.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable @Serializable data class OrderRemote( - val id: Int? = 0, + val id: Int? = null, val date: String = "", val sum: Int = 0, val userId: Int = 0, @@ -19,7 +19,7 @@ fun OrderRemote.toOrder(): Order = Order( ) fun Order.toOrderRemote(): OrderRemote = OrderRemote( - orderId, + null, date, sum, userId diff --git a/app/src/main/java/com/example/flowershopapp/API/Model/UserRemote.kt b/app/src/main/java/com/example/flowershopapp/API/Model/UserRemote.kt index 210e073..2263fa3 100644 --- a/app/src/main/java/com/example/flowershopapp/API/Model/UserRemote.kt +++ b/app/src/main/java/com/example/flowershopapp/API/Model/UserRemote.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable @Serializable data class UserRemote( - val id: Int = 0, + val id: Int? = null, val userName: String = "", val dateOfBirth: String = "", val phoneNumber: String = "", @@ -21,7 +21,7 @@ fun UserRemote.toUser(): User = User( ) fun User.toUserRemote(): UserRemote = UserRemote( - userId ?: 0, + null, userName, dateOfBirth, phoneNumber, diff --git a/server/data.json b/server/data.json index 7e12944..00b5412 100644 --- a/server/data.json +++ b/server/data.json @@ -137,6 +137,12 @@ "date": "2023-12-25", "sum": 1200, "userId": 2 + }, + { + "date": "2023-12-25", + "sum": 2424, + "userId": 2, + "id": 5 } ], "users": [ @@ -212,6 +218,12 @@ "bouquetId": 1, "count": 1, "id": 6 + }, + { + "orderId": 5, + "bouquetId": 2, + "count": 1, + "id": 7 } ] } \ No newline at end of file