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 delete API endpoint

Create the delete API endpoint

- [Instructor] In this part, we are going to add a new action and this action is going to be used to delete a transaction from the database. This is basically the last feature of that section. We are going to create an action which is going to handle an HttpDelete request from the Angular app, and then it's going to remove the data from the database and then return or send a response back to the Angular app. For that, let us go to Visual Studio. In here, when we delete an app from the database, we don't need to pass any data from the request body. We just need the transaction id, which we can pass in the request URL. So for that, after the HttpPut, I'm going to use HttpDelete, and then to follow the same coding conventions, I'm going to use in here either Delete or Remove, and then pass as a parameter, id. Then, down here, the same as in the other actions, I'm going to use IActionResult DeleteTransaction, pass as a parameter the id. Let us first check if the transaction with this id…

Contents