Integration with the data layer
The response from our APIs may or may not look like our domain models. Instead, their structure can resemble the fields that the UI or Views need to bind. Hence, it is recommended to create a separate set of POCO classes that integrates with our UI. These POCOs are known as Data Transfer Objects (DTOs).
In this section, we will implement our DTOs, domain logic integrating with the data layer, and integrate the cache services discussed in Chapter 8, Understanding Caching, using the Cache-Aside pattern, and then finally the required RESTful APIs using controllers and actions. Along the way, we will use HTTP Client factory for our service-to-service communication, and the AutoMapper
library for mapping domain models to DTOs.
We will pick a products service that is part of Packt.Ecommerce.Product
, a web API project using .NET 5, and discuss its implementation in detail. By the end of this section, we will have implemented the projects highlighted...