From the course: Build Spring Boot Apps with the Kotlin Programming Language

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Solution walk-through

Solution walk-through

- [Instructor] So I hope you've had a go at that, I'll do the walkthrough now. We'll start in the booking service. So what we want to do is say, is there a booking for that seat and that performance? So I want to make use of the booking repository, we'll need to inject it into this class. So we'll start by autowiring in a lateinit var called bookingRepository, which is an object of type BookingRepository. Okay, so now in isSeatFree, we can say, let's get all of the bookings first of all, and that will be our bookingRepository.findAll. Then we can say our matched bookings are, take the bookings, filter on them, and we're interested in those bookings where the seat is equal to the seat that's been passed into this function, and the performance is equal to the performance passed into this function. So, now our matched bookings is a list of bookings that could be of size zero or one. I suppose in theory it could be bigger than one, but we want to know, is it zero or not really? If it is…

Contents