A heavily used pattern in DDD
, is service pattern
.
My question is, where is the logic for references to "daughters"?
For example, a use case, Pedido
that has Produtos
public class Pedido
{
public int Id {get;set;}
public int ClienteId {get;set;}
public Cliente Cliente {get;set;}
public ICollection<PedidoProduto> Produtos {get;set;}
}
public class PedidoProduto
{
public int Id {get;set;}
public int PedidoId {get;set;}
public int ProdutoId {Get;set;}
public Pedido Pedido {get;set;}
public Produto Produto {get;set;}
}
Let's go to a Controller Action
public ActionResult Create(Pedido model, int[] Produtos)
{
//Lógica...
}
Well ... the logic of handling the request and its Products goes within PedidoService
, thus leaving only my Controller
dependence with only 1 Service
, and within PedidoService
have dependency of PedidoRepository
and ProdutoRepository
, or is there a need to create 2 Service
and make Controller
depend on 2 Service
?