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
From the course: Building Angular and ASP.NET Web API Apps
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
-
-
-
-
Create an empty Web API Project9m 4s
-
(Locked)
Define application models5m 47s
-
(Locked)
Configure entity framework for database access13m 55s
-
(Locked)
Build the Create API endpoint10m 41s
-
(Locked)
Create the read-all API endpoint3m 4s
-
(Locked)
Create the read by ID API endpoint6m 55s
-
(Locked)
Create the update API endpoint7m 4s
-
(Locked)
Create the delete API endpoint3m 10s
-
(Locked)
Cleanup Code16m 24s
-
-
-
-
-