Beispiel #1
0
        public static CreateMultiLingualMapResult <TMultiLingualEntity, TTranslation, TDestination> YCreateMultiLingualMap <TMultiLingualEntity, TMultiLingualEntityPrimaryKey, TTranslation, TDestination>(
            this IMapperConfigurationExpression configuration, MultiLingualMapContext multiLingualMapContext)
            where TTranslation : class, IEntityTranslation <TMultiLingualEntity, TMultiLingualEntityPrimaryKey>
            where TMultiLingualEntity : IMultiLingualEntity <TTranslation>
        {
            var result = new CreateMultiLingualMapResult <TMultiLingualEntity, TTranslation, TDestination>();

            result.TranslationMap = configuration.CreateMap <TTranslation, TDestination>()
                                    .ForMember("Id", p => p.Ignore());
            //.ForMember("CreationTime", p => p.Ignore());
            result.EntityMap = configuration.CreateMap <TMultiLingualEntity, TDestination>().AfterMap((source, destination, context) =>
            {
                var translation = source.Translations.FirstOrDefault(pt => pt.Language == CultureInfo.CurrentUICulture.Name);
                if (translation != null)
                {
                    context.Mapper.Map(translation, destination);
                    return;
                }

                var defaultLanguage = multiLingualMapContext.SettingManager
                                      .GetSettingValue(LocalizationSettingNames.DefaultLanguage);

                translation = source.Translations.FirstOrDefault(pt => pt.Language == defaultLanguage);
                if (translation != null)
                {
                    context.Mapper.Map(translation, destination);
                    return;
                }

                translation = source.Translations.FirstOrDefault();
                if (translation != null)
                {
                    context.Mapper.Map(translation, destination);
                }
            });

            return(result);
        }
Beispiel #2
0
 public static CreateMultiLingualMapResult <TMultiLingualEntity, TTranslation, TDestination> YCreateMultiLingualMap <TMultiLingualEntity, TTranslation, TDestination>(this IMapperConfigurationExpression configuration, MultiLingualMapContext multiLingualMapContext)
     where TTranslation : class, IEntity, IEntityTranslation <TMultiLingualEntity, int>
     where TMultiLingualEntity : IMultiLingualEntity <TTranslation>
 {
     return(configuration.YCreateMultiLingualMap <TMultiLingualEntity, int, TTranslation, TDestination>(multiLingualMapContext));
 }
Beispiel #3
0
            public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
            {
                configuration.CreateMultiLingualMap <ProductCategory, ProductCategoryTranslation, ProductCategoryDto>(context);
                configuration.CreateMap <ProductCategoryCreateDto, ProductCategory>();
                configuration.CreateMap <ProductCategoryUpdateDto, ProductCategory>();
                configuration.CreateMap <ProductCategoryTranslationDto, ProductCategoryTranslation>();

                configuration.CreateMultiLingualMap <Product, ProductTranslation, ProductDto>(context);
                configuration.CreateMap <ProductCreateDto, Product>();
                configuration.CreateMap <ProductUpdateDto, Product>();
                configuration.CreateMap <ProductTranslationDto, ProductTranslation>();
            }
Beispiel #4
0
 internal static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
 {
     configuration.CreateMultiLingualMap <Country, CountryTranslation, CountryDto>(context);
 }
Beispiel #5
0
        public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
        {
            configuration.CreateMultiLingualMap <Product, ProductTranslation, ProductListDto>(context, true);

            configuration.CreateMap <ProductCreateDto, Product>();
            configuration.CreateMap <ProductUpdateDto, Product>();

            configuration.CreateMap <ProductTranslationDto, ProductTranslation>();

            configuration.CreateMultiLingualMap <Order, OrderTranslation, OrderListDto>(context, true)
            .EntityMap.ForMember(dest => dest.ProductCount, opt => opt.MapFrom(src => src.Products.Count));
        }
Beispiel #6
0
 public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
 {
     configuration.CreateMultiLingualMap <Profession, long, ProfessionTranslations, GetProfessionsDto>(context);
     configuration.CreateMultiLingualMap <Profession, long, ProfessionTranslations, GetProfessionDto>(context);
 }
Beispiel #7
0
        public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
        {
            //configuration.YCreateMultiLingualMap<Product, ProductTranslation, ProductListDto>(context);



            #region Category
            configuration.CreateMap <PostCategoryTranslationDto, CreateOrEditPostCategoryDto>().IgnoreAllNonExisting(new MapperConfiguration((MapperConfigurationExpression)configuration));
            configuration.YCreateMultiLingualMap <PostCategory, PostCategoryTranslation, PostCategoryDto>(context);

            #endregion

            #region Post
            configuration.CreateMap <PostTranslationDto, CreateOrEditPostDto>().IgnoreAllNonExisting(new MapperConfiguration((MapperConfigurationExpression)configuration));
            configuration.YCreateMultiLingualMap <Post, PostTranslation, PostDto>(context);
            //.EntityMap.ForMember(u => u.CategoryName, options => options.MapFrom(input => input.Category.Name));
            #endregion

            #region Topic

            #region Topic category
            configuration.CreateMap <TopicCategoryTranslationDto, CreateOrEditTopicCategoryDto>().IgnoreAllNonExisting(new MapperConfiguration((MapperConfigurationExpression)configuration));
            #endregion

            #region Topic
            configuration.CreateMap <TopicTranslationDto, CreateOrEditTopicDto>().IgnoreAllNonExisting(new MapperConfiguration((MapperConfigurationExpression)configuration));
            configuration.YCreateMultiLingualMap <Topic, TopicTranslation, TopicDto>(context);
            #endregion

            #endregion

            //#region Organizer
            //configuration.CreateMap<OrganizerTranslationDto, CreateOrEditOrganizerDto>().IgnoreAllNonExisting(new MapperConfiguration((MapperConfigurationExpression)configuration));
            //configuration.YCreateMultiLingualMap<Organizer, OrganizerTranslation, OrganizerDto>(context);

            //#endregion

            configuration.CreateMap <ApplicationLanguage, ApplicationLanguageEditDto>()
            .ForMember(u => u.IsEnabled, options => options.MapFrom(input => !input.IsDisabled));
        }
 public static void CreateMappings(IMapperConfigurationExpression configuration, MultiLingualMapContext context)
 {
     configuration.CreateMultiLingualMap <Block, long, BlockTranslations, GetBlockDto>(context);
     //  configuration.CreateMultiLingualMap<Block, long, BlockTranslations, GetProfeDto>(context);
 }