M
M
Mikhail Ivanov2017-06-08 17:56:26
ASP.NET
Mikhail Ivanov, 2017-06-08 17:56:26

Do I need a business logic layer?

I develop API in C# (ASP.NET Core). The data access layer is divided into many modules (eg authorization module: contains models and repositories associated with authorization, the library module contains models and repositories associated with books, etc., etc.).
It was planned to use all these modules in a project with an API, and write all the logic in controllers. Is this a good idea? Or is it better to create a separate project in which all business logic will be described, and use it in a project with an API? If you create a separate project for the BL, then what about the models? It turns out that there will be database models, business logic models and models that I will give / receive from the user in the API.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-06-09
@qonand

I completely agree with Tolstoy Lorry and Arkadiy Parinov , on my own I would like to add
This is a bad idea and goes against MVC. The controller should not contain business logic, it should only contain the logic for processing the user's request and that's it.
Whether business logic needs to be moved to separate projects or not depends on whether it will be necessary to use it in other projects or not. But it’s definitely worth isolating the business logic layer from the UI layer and the data access layer
Read about splitting the application into layers, DDD and these questions will disappear on their own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question