简体   繁体   中英

Common Business Layer for a new Web API and existing ASP .NET Web site Solution

We have an active fully developed ASP.NET web application which allows users to create/update data for various screens/modules.

Now, There is a requirement to build a Web API that will automate the data creation for a particular module alone.

This API will receive data from source system and saves the posted data to our application database (eventually removing the front-end option to create)

The Web Solution has it's own Business & Data Layer included in the solution and we are looking at ways to re-use the layers in the API as well.

One way I can think of is to refer the Business layer as a dll in the Web API but this would provide access to other classes & methods in the BL which is not required at this point

Can anyone please suggest what is the right approach?

splitting up a solution into multiple projects is not a bad thing. One project for your BLL, another for your DAL is a good approach and I would definitely recommend going with that.

Yes, it does mean that if you add a reference to the BLL project into the API then yes, the API will have access to more than it needs for now, but that is not really an issue. How much you use is up to you.

Plus, if you start using the API you will probably find that more and more code will naturally converge towards that so having access to everything will make life easier, long term.

You could also break out the specific bit of code you are interested in into an extra project / dll and reference that in the API, if you see value in that, but I don't think that's particularly useful.

Another thing that I highly recommend is to have a separate project for your model classes, it makes things much easier when it comes to sharing them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM