Folders
To organize our application, we will create the following folders:
Controllers
Data
Interfaces
Repositories
Services
Let’s briefly explain what these are:
- The client is the application calling the API (for example, the website or mobile application). The
Controllers
folder will hold methods that act as endpoints (an endpoint is what the client connects to via a URL). - The
Data
folder will hold the definition of our entities – in our case, theCar
object shown earlier. - The
Interfaces
folder is just what it sounds like: it will hold the interfaces to our C# objects. - The
Repositories
folder will hold the code between our methods and the database calls. - The
Services
folder will hold supporting code.
The flow will be as follows:
- The client calls a method in a controller.
- The method calls a service to handle the business logic.
- The service calls a method in the repository, which, in turn,...