This section updates the Delete methods for ASP.NET Core.
- [Instructor] The final action method to migrate is the delete method. Now we already have a delete in here. So we just need to remove the response type. And the original project did use some attribute routing. And this route construct rewinds the route to the beginning and then adds in the delete ID and timestamp. We don't actually to rewind to the beginning because our default route for the controller is API shopping cart. So we can delete those and then move what's left from the route attribute to the HTTP delete attribute.
And remove the route. Once again, we change the IHTTP action result to an action result. Get rid of the try catch. We are already returning a concurrency error. And bad request, if we get a concurrency exception. So, our delete method becomes very very streamlined. The last thing we'll change is a dispose method. We don't actually have to dispose of the repo because that's being controlled by the dependency injection container.
So we can delete that and we have completed migrating the shopping cart controller.
- Creating the .NET Core project
- Adding Entity Framework
- Migrating the data access layer (DAL)
- Configuring services and the HTTP pipeline
- Adding remaining services to the dependency injection container
- Migrating controllers and actions
- Testing the services