0
Good software architecture practice says that the presentation layer does not You must know the domain layer. I’m trying to make this isolation between these layers, but the that is hindering this separation is the mapping framework of objects, the Automapper.
I have the following scenario:
Presentation Layer > Application Layer > Domain Layer
In the Domain layer I have the Client entity. In the Presentation layer I have the Clienteviewmodel.
To map these classes, I use the Automapper. The problem is that your configuration is made in the Presentation layer, and this way ends that this layer has who knows the domain.
//Método da classe DomainToViewModelMappingProfile que está na Presentation
protected override void Configure()
{
// Faz referência ao Cliente do domínio.
Mapper.CreateMap<Cliente, ClienteViewModel>();
}
// Métodos da classe ClienteMapper
public static ClienteViewModel MapearClienteParaClienteViewModel(Cliente cliente)
{
return Mapper.Map<Cliente, ClienteViewModel>(cliente);
}
public static Cliente MapearClienteViewModelParaCliente(ClienteViewModel clienteView)
{
return Mapper.Map<ClienteViewModel, Cliente>(clienteView);
}
I tried to play the Automapper on the Application layer, but how it references the domain not to reference Presentation, because there is a problem of circular function.
What would be the best way to do this isolation?
Thanks Nicolas! But when downloading some projects do not load.
– Raphael
The Equinox.UI.Site and Equinox.Webapi projects have failed to load: the specified 'Microsoft.NET.Sdk.Web' SDK could not be found.
– Raphael
So guy this project stays in Dot.Net Core, which has the SDK in visual studio 2017, so if you try to load with visual studio 2015 down they don’t have the compatibility. an option and load with the visual code. Visual Code
– Nicolas Sylverio