From the course: Building Angular and ASP.NET Web API Apps

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Create the read-all API endpoint

Create the read-all API endpoint

- [Instructor] In this part, we're going to create a new API endpoint. We're going to use this API endpoint to read all the data. So basically whenever the user navigates to the transactions view, we want to be able to send an HttpGet request to the API endpoint, which is going to return all transactions. For that, let's go to Visual Studio. Now because we created the controller on the last part, in this part we're just going to add a new action. So in the TransactionsController just before the HTTP post, we are going to create a method or an API endpoint, which is going to handle the HttpGet requests from the Angular app. The return type the same way is going to be just public IActionResult. And then we can end this either Get or GetAll. And then inside here, we are going to use the AppDbContext to get all the transactions data from the database. For that, I'll just type var allTransactions. And then context.Transactions.ToList. So this way, the Entity Framework is going to read the…

Contents