File tree 1 file changed +18
-0
lines changed
src/main/kotlin/application/service
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ package application.service
11
11
import application.presenter.api.model.RoomEntry
12
12
import application.presenter.api.serializer.ApiSerializer.toRoomEntry
13
13
import entity.zone.Room
14
+ import entity.zone.RoomEnvironmentalData
14
15
import entity.zone.RoomID
15
16
import usecase.repository.RoomRepository
16
17
import java.time.Instant
@@ -59,4 +60,21 @@ object RoomService {
59
60
class GetAllRoomEntry (private val roomRepository : RoomRepository ) : ApplicationService<Set<RoomEntry>> {
60
61
override fun execute (): Set <RoomEntry > = this .roomRepository.getRooms().map { it.toRoomEntry() }.toSet()
61
62
}
63
+
64
+ /* *
65
+ * Application Service that has the objective of updating the [environmentalData] about a room identified
66
+ * by its [roomId]. The data refers to a specific [dateTime] and it is updated via the provided
67
+ * [roomRepository].
68
+ */
69
+ class UpdateRoomEnvironmentData (
70
+ private val roomId : RoomID ,
71
+ private val environmentalData : RoomEnvironmentalData ,
72
+ private val dateTime : Instant ,
73
+ private val roomRepository : RoomRepository
74
+ ) : ApplicationService<Boolean> {
75
+ override fun execute (): Boolean =
76
+ if (this .roomRepository.findBy(roomId, null ) != null ) {
77
+ this .roomRepository.updateRoomEnvironmentalData(roomId, environmentalData, dateTime)
78
+ } else false
79
+ }
62
80
}
You can’t perform that action at this time.
0 commit comments