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

Unlock this course with a free trial

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

Cleanup Code

Cleanup Code

- [Instructor] In this part we're going to clean up the transactions controller and for that let us go to Visual Studio. Now the reason why we need to clean up the controller is because in the actions within this controller we do also have some logic like for example, we get the data from the database, we then update the data, we send the data back to the database and then we just return a response. A controller action is not supposed to do this kind of stuff. The database interaction should always be done by a different file and in an action we should only have the request received. So we just get the request, we process the request inside here and then just return a response to the user. So the actions within a controller should always be as simple as possible. When we have database access, we should always remove this logic from here to a different file. For these files we use a different name. We call these files the services of an app. So for that let us just go to the solution…

Contents