Skip to content

Commit ef19105

Browse files
chore: add check of pre-existance when creating a new room digital twin
1 parent f3622e1 commit ef19105

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/kotlin/application/service/Service.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ object Service {
3434
* Application Service that has the objective of creating a [room] using the provided [roomRepository].
3535
*/
3636
class CreateRoom(private val room: Room, private val roomRepository: RoomRepository) : ApplicationService<Room?> {
37-
override fun execute(): Room? = this.roomRepository.createRoom(room)
37+
override fun execute(): Room? =
38+
if (this.roomRepository.findBy(room.id, null) == null) {
39+
this.roomRepository.createRoom(room)
40+
} else null
3841
}
3942

4043
/**

0 commit comments

Comments
 (0)