12 Using IAsyncEnumerable<T> and yield return

 

This chapter covers

  • Using the generic Queue data structure
  • Using yield return and IAsyncEnumerable<T>
  • Creating Views
  • Using private getters and setters with auto-properties
  • How structs differ from classes
  • Using checked and unchecked keywords

In the previous chapters, we examined the code base we inherited and noted where we could make improvements. Then, we partially implemented our version of the code base, adhering to FlyTomorrow’s OpenAPI specification. In chapters 10 and 11, we implemented the BookingService class and decided that there was no need for a CustomerService class.

Figure 12.1 In this chapter we wrap up the services layer by implementing the AirportService and FlightService class. By implementing those classes, we finish the service layer rewrite of the Flying Dutchman Airlines service.

If we look at which classes we need to implement to complete our service layer, we see an encouraging picture:

  • CustomerService (Chapter 10)
  • BookingService (Chapter 10 and 11)
  • AirportService (this chapter)
  • FlightService (this chapter)

We are halfway done with the service layer classes. In this chapter, we wrap up the service layer implementation by writing code for the AirportService and FlightService classes. After this chapter, we are in an excellent spot to move on to our last architectural layer: the controller layer.

12.1   Do we need an AirportService class?

12.2   Implementing the FlightService class

12.2.1   Getting information on a specific flight from the FlightRepository

12.2.2   Combining two data streams into a View

12.2.3   Using the yield return keywords with try-catch code blocks

12.2.4   Implementing GetFlightByFlightNumber

12.3   Exercises

12.4   Summary