예제 #1
0
        public MappingProfile()
        {
            //此文件中添加所有的实体到实体间的映射
            ///CreateMap<AdminUsers, AdminUsersDto>();
            CreateMap <AdminUsersDto, AdminUsers>()
            .ForMember(p => p.Id, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
            .ForMember(p => p.PassWord, opt => opt.MapFrom(src => EncryptDecrypt.EncryptMD5(src.PassWord)))
            .ForMember(p => p.State, opt => opt.MapFrom(src => 0))
            .ForMember(p => p.ReferrerID, opt => opt.MapFrom(src => 0))
            .ForMember(p => p.BusinessID, opt => opt.MapFrom(src => 0))
            .ForMember(p => p.IsDisabled, opt => opt.MapFrom(src => false))
            .ForMember(p => p.AddTime, opt => opt.MapFrom(src => DateTime.Now))
            .ForMember(p => p.ValidityTime, opt => opt.MapFrom(src => DateTime.Now))
            .ForMember(p => p.HeadPortraitUrl, opt => opt.Ignore()).ReverseMap();

            CreateMap <ProductInfoDto, ProductInfoToClass>()
            .ForMember(p => p.BusinessID, t => t.Ignore())
            .ForMember(p => p.ID, t => t.MapFrom(s => s.ID))
            .ForMember(p => p.ClassID, t => t.MapFrom(s => s.ClassID))
            .ForMember(p => p.ProductID, t => t.MapFrom(s => s.ProductID)).IgnoreAllPropertiesWithAnInaccessibleSetter();
            ////Source->Destination2
            ////CreateMap<Source, Destination2>().ForMember(d => d.AnotherValue2, opt =>
            ////{
            ////    opt.MapFrom(s => s.AnotherValue);
            ////});

            //Mapper.AssertConfigurationIsValid();
        }
예제 #2
0
 public MappingProfile()
 {
     //此文件中添加所有的实体到实体间的映射
     ///CreateMap<AdminUsers, AdminUsersDto>();
     CreateMap <RegisterInput, AdminInfo>()
     .ForMember(p => p.Id, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
     .ForMember(p => p.LoginName, opt => opt.MapFrom(src => src.LoginName))
     .ForMember(p => p.PassWord, opt => opt.MapFrom(src => src.PassWord))
     .ForMember(p => p.Mobile, opt => opt.MapFrom(src => src.Mobile))
     .ForMember(p => p.SaltKey, opt => opt.MapFrom(src => Guid.NewGuid()))
     .ForMember(p => p.IsDel, opt => opt.MapFrom(src => false))
     .ForMember(p => p.State, opt => opt.MapFrom(src => 1))
     .ForMember(p => p.CreateTime, opt => opt.MapFrom(src => DateTime.Now)).ReverseMap();
     CreateMap <ContactInfoInput, ContactInfo>()
     .ForMember(p => p.Id, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
     .ForMember(p => p.Mobile, opt => opt.MapFrom(src => src.Mobile))
     .ForMember(p => p.HotwireTelephone, opt => opt.MapFrom(src => src.HotwireTelephone))
     .ForMember(p => p.Email, opt => opt.MapFrom(src => src.Email))
     .ForMember(p => p.WeChat, opt => opt.Ignore())
     .ForMember(p => p.Address, opt => opt.MapFrom(src => src.Address))
     .ForMember(p => p.QQ, opt => opt.MapFrom(src => src.QQ))
     .ForMember(p => p.IsEnabled, opt => opt.MapFrom(src => true)).ReverseMap();
     CreateMap <ContactInfo, ContactInfoOutput>()
     .ForMember(p => p.WeChat, opt => opt.MapFrom(src => Convert.ToBase64String(src.WeChat)));
     CreateMap <ProductClassInput, ProductClass>()
     .ForMember(p => p.Id, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
     .ForMember(p => p.ClassID, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
     .ForMember(p => p.IsEnabled, opt => opt.MapFrom(src => true))
     .ForMember(p => p.ClassName, opt => opt.MapFrom(src => src.ClassName));
     CreateMap <ProductsAddInput, Products>()
     .ForMember(p => p.Id, opt => opt.MapFrom(src => SingletonIdWorker.GetInstance().NextId()))
     .ForMember(p => p.ImageUrl, opt => opt.Ignore())
     .ForMember(p => p.Price, opt => opt.MapFrom(src => src.Price ?? 0));
     //Mapper.AssertConfigurationIsValid();
 }