Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Domain Service Problerm #1195


User avatar
0
anderyuan created

In the abp.net zero, I see you use the DomainService(ex. UserManager) in the Controller, but in the docs , you see the domain service not directly used by presentation layer , why?


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Actually, this is a good discussion topic. I will not write much, but in brief, I think:

    Domain layer (entities, services) should not be available to presentation layer like that: You should not somehow directly call domain services and transfer entities between client and server (for example, in an AJAX request). But an MVC Controller is like application services and they can use domain objects. MVC Controller is not direct part of presentation layer (it's a mediator between presentation and domain, like application services) and we can use domain objects in controllers as long as the they include domain logic.

    But.. if you think that the code in the Controller should be reusable and MVC can be replaced by another library (like Nancy) for you project in the future, I suggest you to create application services even for MVC projects. Because application services are much more plain classes those can be usable across different presentation frameworks.