My project in ASP.NET MVC in C # has a Domain layer where I have entities, and business rules. I need to add a new rule where I should return an object with an internal list, but I ended up having a discussion about DDD rules with my colleagues and some defend the thesis that this object even being used by domains routines, can not stay in the Domain.
So I started using dynamic, but when I get to the automapper it has problems converting.
I would like to know the opinion of those who have more experience with DDD, or who can suggest a project, idea or solution to this problem.
Example:
A Estrutura é a seguinte:
1) Web
Automaper
View (Com Entidades do banco de dados e outas)
2) Application
3) Domain
Entites (Entidades do banco de dados)
Services (Onde ficam as regras de negocios)
4) Repository
Dapper
Entites Repository
5)Ioc
Now I need to create a routine that calculates certain information this I did in 3) Domain - > Service "FluxoService", inside I have the method that returns a list type "Flow" So "Flow" is not an entity and does not persist in the database, can this "Flow" object stay in the domain?
If you can not, how can I return data of this type "Flow"?
Another example: I made a select using dapper (4) Repository the return of this select I created a class called "MyData" To return to 1) Web I will need to go through 3) Domain - > Service (MyDomainService calls MyDomainRepository ((4) Repository) how can I return "MyData" to layer 1) if the "MyData" Class can not be put into the domain?
Maybe the solution would be to use subdomain? Does anyone use the same structure as mine? or to use will I have to change the structure?
Another example: MusicStoreDDD In this project Cart is an entity and place in the Domain Now I want to add Flow and FlowService that are not entities and do not persist
Can these be in the domain?
public class CartService : Service<Cart>, ICartService
{
public CartService(ICartRepository repository, ICartReadOnlyRepository readOnlyRepository)
: base(repository, readOnlyRepository)
{
}
}
public class FluxoService : IFluxoService
{
private readonly ICartService _service;
public CartService(ICartRepository repository, ICartReadOnlyRepository readOnlyRepository, ICartService service)
: base(repository, readOnlyRepository)
{
_service = service;
}
public List<Fluxo> ProcessarFluxo()
{
return new List<Fluxo>().ToList();
}
}