I have forms that make AJAX calls for data like below:
$.ajax({ url: "/adminTasks/GetJsonDSData",
data: { ABC: "Abc" },
success: function (data) {
etc.
The calls work fine but add to the code in my controllers. I would like to move the methods behind these calls outside of the controllers but I am not sure how to do this. Seems like all the calls must be routed to a URL of a controller.
I had the idea to move the methods into helper classes in my storage project. This works fine and now I can have the action go to the controller which then calls the storage methods and which then returns data to the controller.
Is there any way I can take the controllers out of the loop to simplify things?
My suggestion is to make sure that all code related to obtaining data from the datbase is in your service layer.
Your controller will be making calls to the service to receive specific data for the purpose of sending it to the front end.
If you feel that you have too many JSON methods in your adminTasks controller I recommend you move them to a more appropriate controller.