IMapper mapper = new Mapper(AutoMapperConfig.ConfigureAutoMapper());
services.AddSingleton(mapper);
#Конфигурация маппера
public static class AutoMapperConfig
{
public static MapperConfiguration ConfigureAutoMapper()
{
MapperConfiguration configuration = new MapperConfiguration(confg =>
{
confg.CreateMap<AddPersonViewModel, PersonDTO>();
#и тд
public static void AddDALServices(this IServiceCollection services)
{
IMapper mapper = new Mapper(AutoMapperConfiguration.ConfigureAutoMapper());
services.AddSingleton(mapper);
#Конфигурация маппера
public static class AutoMapperConfiguration
{
public static MapperConfiguration ConfigureAutoMapper()
{
MapperConfiguration configuration = new MapperConfiguration(confg =>
{
confg.CreateMap<Person, PersonDTO>();.
#и так далее
public PersonService(IUnitOfWork unitOfWork, IMapper mapper, ILogger<PersonService> logger)
{
this.unitOfWork = unitOfWork;
this.mapper = mapper;
this.logger = logger;
}
public PersonController(IPersonService personService, ILogger<PersonController> logger, IMapper mapper)
{
this.personService = personService;
this.logger = logger;
this.mapper = mapper;
}