I have a small site that I implemented using AngularJS, C # and Entity Framework. The entire site is a one-page application and gets all its data from a single C # web service.

My question is about the interface that the C # web service should show. This time, the service can provide objects in a RESTful way, by providing them directly or as a DTO. Another approach would be for the web service to return an object for only one use case, so the AngularJS controller only needs to call the web service once and can work directly with the responding model.
To clarify, consider the following two snippets:
and
While the first example provides a RESTful interface and works with a resource metaphor, it has a huge disadvantage of only returning pieces of data. The second example returns an object adapted to the needs of the MVC, but most likely it will be used in only one MVC. In addition, in the second scenario, you need to perform many mappings for common fields.
I found that from time to time I did both things in my web service and I want to get some feedback about this. I don’t really like work, although a few queries are, of course, problematic, and when they slow down the application too much, they need refactoring. What is the best way to develop a web service interface?
source share