Please use repository pattern to split all the communication between the application and your data source. and call the repository functions inside your controller. It is good practice. Here is an article you can understand about that
Your functions can be separate from controller to repository.
Move your functions an repository and call them into your controller.