How to reduce template code for web api calls?

I am working with an ASP.NET MVC website and ASP.NET Web Api. The current architecture is as follows:

Browser => UI website => Web Api service => databases

The argument for separating UI and Web Api was that we can have several different user interfaces (website, mobile, work, clock, etc.), all calling intermediate services to receive data. However, when I need to add a new api call, I need to add quite a lot of tile code (+ template tests that I no longer like).

Browser => ajax 
    UI => controller and web api proxy client
Web API => controller and repository
           database

I think it would be easier to combine the web api with the user interface, since I will not need to write additional controllers and proxies for the call, however I'm not sure if this is the right way. We have about 20 controllers and 100 api calls written in C #. I am interested to know how other users use web api along with user interface projects.

Should I combine a Web Api project with a user interface project and what are the pros and cons of this?

+4
source share

Source: https://habr.com/ru/post/1615732/


All Articles