2
My ASP.NET MVC project 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 Dominio routines, can not stay in Dominio.
So I started using Dynamic, but when arriving at automapper it presents problems for conversion.
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, this "Flow" object can be in Domain?
If Can’t, 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 the 1) Web I will need to go through the 3)Domain -> Service (Meusdadosservice calls Meusdadosrepository((4) Repository) how can I return "Mydata" to layer 1) Web if the "Mydata" Class cannot be placed in Domain?
Maybe the solution would be to use subdomain? someone uses with the structure similar to mine? or to use will have to change the structure?
another example: Musicstoreddd In this project Cart is an entity and will be in the Domain Now I want to add Flow and Fluxoservice that are not entities and do not persist
These can be on 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();
}
}
You have a
entity
that will consume this new rule. Does this new rule refer to business rule or just a data formatting for display? This list that will be returned will be used by aentity
or at all? Will this rule validate? Will this new rule depend on other services? Do I need these details to help you– DNick
Onde colocar um objeto (...)
( ° ʖ °)– Oralista de Sistemas
I edited the question and added other information
– nfrigo
@nfrigo a look you can use DTO to do what you want in your https://answall.com/questions/33005/utilizes%C3%A7%C3%A3o-de-dto-e-viewmodel-in-project-Asp-net-mvc repository
– Eduardo Sampaio
The communication structure is 1) Web -> Flame 2) Application (Here have the transactions) -> calls the 3) service (business rules) ->calls 4) Repository, the return of the data makes the reverse path 4,3,2,1. So I can’t call the Repository or the web layer service, but thank you @Eduardosampaio
– nfrigo
then in the web layer will have a viewmodel that will wait for everything you need that will send to where you want .
– Eduardo Sampaio
but where I put the DTO, it can stay in the domain?
– nfrigo