Ejemplo n.º 1
0
        public static IMapper FakeMapper()
        {
            var myProfile = new Massoterapia.Application.user.Mappings.UserDomainToUserTobeCreatedMappingProfile();

            var patientDomainToPatientViewModelListMappingProfile = new Massoterapia.Application.Patient.Mappings.PatientDomainToPatientViewModelListMappingProfile();

            var BlogDomainToBlogViewModelMappingProfile = new Massoterapia.Application.Blog.Mappings.BlogDomainToBlogViewModelMappingProfile();

            var blogInputModelToBlogDomainMappingProfile = new Massoterapia.Application.Blog.Mappings.BlogInputModelToBlogDomainMappingProfile();

            List <Profile> profiles = new List <Profile>();

            profiles.Add(myProfile);
            profiles.Add(patientDomainToPatientViewModelListMappingProfile);
            profiles.Add(BlogDomainToBlogViewModelMappingProfile);
            profiles.Add(blogInputModelToBlogDomainMappingProfile);


            var configuration = new MapperConfiguration(cfg => cfg.AddProfiles(profiles));


            return(configuration.CreateMapper());  //new Mapper(configuration);
        }
        public static void AddAutoMapperMiddleware(this IServiceCollection services)
        {
            var myProfileUser    = new Massoterapia.Application.user.Mappings.UserDomainToUserTobeCreatedMappingProfile();
            var myProfilePatient = new Massoterapia.Application.Patient.Mappings.PatientDomainToPatientViewModelListMappingProfile();

            var myProfileBlogDomainToViewModel = new Massoterapia.Application.Blog.Mappings.BlogDomainToBlogViewModelMappingProfile();
            var myProfileBlogInputToDomain     = new Massoterapia.Application.Blog.Mappings.BlogInputModelToBlogDomainMappingProfile();


            List <Profile> profiles = new List <Profile>();

            profiles.Add(myProfileUser);
            profiles.Add(myProfilePatient);
            profiles.Add(myProfileBlogDomainToViewModel);
            profiles.Add(myProfileBlogInputToDomain);


            var configuration = new MapperConfiguration(cfg => cfg.AddProfiles(profiles));

            IMapper mapper = configuration.CreateMapper();  //new Mapper(configuration);

            //services.AddSingleton(mapper);
            services.AddSingleton <IMapper>(p => mapper);
        }