Since the released of Web API, I've been wondering whether it's necessary or helpful to migrate/change MVC controllers to use Web API calls. Since it's hard to describe code I'll show an example of what I mean:
Current controller, the _userService
is basically the Business
layer of the application that is then calling the repository and getting all users.
[HttpGet]
public ActionResult List()
{
var list = _userService.GetAll();
if(list.Any())
return View("List",list);
return View(list.ToList());
}
Would it be better to use Web API, and get the list of the users as JSON object and then bind it to the view with some JavaScript? (possibly knockout if applicable).
Not sure if my question is clear enough, so let me know if I have to explain something.