Beispiel #1
0
 public static void AddMappings(AutoMapper.IMapperConfigurationExpression config)
 {
     config.AddProfile <VM.Models.TournamentObservableMappingProfile>();
     config.AddProfile <TournamentTeamObservableMappingProfile>();
     config.AddProfile <PlayerObservableMappingProfile>();
     config.AddProfile <TourObservableMappingProfile>();
     config.AddProfile <TourGameResultObservableMappingProfile>();
     Services.Models.ModelsMappingConfig.AddMappings(config);
 }
Beispiel #2
0
        private static void InitMappings(AM.IMapperConfigurationExpression c)
        {
            foreach (var sourceType in TypeMap)
            {
                foreach (var destType in sourceType.Value)
                {
                    destType.Value.Invoke(c);
                }
            }

            c.CreateMissingTypeMaps = true;
        }
        public static void CompanyEntityToModel(AutoMapper.IMapperConfigurationExpression cfg)
        {
            cfg.CreateMap <CompanyEntity, CompanyModel>()

            .ForMember(dest => dest.Id, opts => opts.MapFrom(s => s.Id))
            .ForMember(dest => dest.Active, opts => opts.MapFrom(s => s.Active))
            .ForMember(dest => dest.EditedOn, opts => opts.MapFrom(s => s.EditedOn))
            .ForMember(dest => dest.City, opts => opts.MapFrom(s => s.City))
            .ForMember(dest => dest.Name, opts => opts.MapFrom(s => s.Name))
            .ForMember(dest => dest.Phone, opts => opts.MapFrom(s => s.Phone))
            .ForMember(dest => dest.State, opts => opts.MapFrom(s => s.State))
            .ForMember(dest => dest.Street, opts => opts.MapFrom(s => s.Street))
            .ForMember(dest => dest.ZipCode, opts => opts.MapFrom(s => s.ZipCode));
        }
        public static void UserEntityToModel(AutoMapper.IMapperConfigurationExpression cfg)
        {
            cfg.CreateMap <UserEntity, UserModel>()

            .ForMember(dest => dest.Id, opts => opts.MapFrom(s => s.Id))
            .ForMember(dest => dest.Active, opts => opts.MapFrom(s => s.Active))
            .ForMember(dest => dest.EditedOn, opts => opts.MapFrom(s => s.EditedOn))
            .ForMember(dest => dest.Email, opts => opts.MapFrom(s => s.Email))
            .ForMember(dest => dest.FirstName, opts => opts.MapFrom(s => s.FirstName))
            .ForMember(dest => dest.LastName, opts => opts.MapFrom(s => s.LastName))
            .ForMember(dest => dest.Password, opts => opts.MapFrom(s => s.Password))
            .ForMember(dest => dest.Company_Name, opts => opts.MapFrom(s => s.Company != null ? s.Company.Name : String.Empty))
            .ForMember(dest => dest.Company_Id, opts => opts.MapFrom(s => s.Company != null ? s.Company.Id : 0));
        }
        public static void CompanyModelToEntity(AutoMapper.IMapperConfigurationExpression cfg)
        {
            cfg.CreateMap <CompanyModel, CompanyEntity>()

            .ForMember(dest => dest.Id, opts => opts.MapFrom(s => s.Id))
            .ForMember(dest => dest.Active, opts => opts.MapFrom(s => s.Active))
            .ForMember(dest => dest.EditedOn, opts => opts.MapFrom(s => s.EditedOn == DateTime.MinValue ? DateTime.Now : s.EditedOn))
            .ForMember(dest => dest.City, opts => opts.MapFrom(s => s.City))
            .ForMember(dest => dest.Name, opts => opts.MapFrom(s => s.Name))
            .ForMember(dest => dest.Phone, opts => opts.MapFrom(s => s.Phone))
            .ForMember(dest => dest.State, opts => opts.MapFrom(s => s.State))
            .ForMember(dest => dest.Street, opts => opts.MapFrom(s => s.Street))
            .ForMember(dest => dest.ZipCode, opts => opts.MapFrom(s => s.ZipCode))
            .ForMember(dest => dest.Users, opts => new List <CompanyEntity>());
        }
        public static void UserModelToEntity(AutoMapper.IMapperConfigurationExpression cfg)
        {
            cfg.CreateMap <UserModel, UserEntity>()

            .ForMember(dest => dest.Id, opts => opts.MapFrom(s => s.Id))
            .ForMember(dest => dest.Active, opts => opts.MapFrom(s => s.Active))
            .ForMember(dest => dest.EditedOn, opts => opts.MapFrom(s => s.EditedOn == DateTime.MinValue? DateTime.Now : s.EditedOn))
            .ForMember(dest => dest.Email, opts => opts.MapFrom(s => s.Email))
            .ForMember(dest => dest.FirstName, opts => opts.MapFrom(s => s.FirstName))
            .ForMember(dest => dest.LastName, opts => opts.MapFrom(s => s.LastName))
            .ForMember(dest => dest.Password, opts => opts.MapFrom(s => s.Password))
            .ForMember(dest => dest.Password, opts => opts.MapFrom(s => s.Password))
            .ForMember(dest => dest.CompanyId, opts => opts.MapFrom(s => s.Company_Id))
            .ForMember(dest => dest.Company, opts => opts.Ignore());
        }
Beispiel #7
0
        public static void Configure(params Assembly[] assembliesToScan)
        {
            assembliesToScan = assembliesToScan ?? new Assembly[] { };

            var allTypes = assembliesToScan
                           .SelectMany(a => a.ExportedTypes)
                           .ToArray();

            var profiles = allTypes
                           .Where(t => typeof(AM.Profile).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()))
                           .Where(t => !t.GetTypeInfo().IsAbstract);

            AM.Mapper.Initialize(c =>
            {
                MapperConfigurationExpression = c;
                profiles.Each(p => c.AddProfile(p));
            });
        }
Beispiel #8
0
 public static void AddMappings(AutoMapper.IMapperConfigurationExpression expr)
 {
     expr.AddProfile <Models.Api.ToDoItemApiModelProfile>();
     expr.AddProfile <CategoryMappingProfile>();
 }
 public MapperConfigurationWrapper(AM.IMapperConfigurationExpression config)
 {
     this.config = config;
 }