Пример #1
0
        public static Store ToWebModel(this VirtoCommerce.Client.Model.VirtoCommerceStoreModuleWebModelStore storeDto)
        {
            var retVal = new Store();
            retVal.InjectFrom(storeDto);
            if(storeDto.SeoInfos != null)
            {
                retVal.SeoInfos = storeDto.SeoInfos.Select(x => x.ToWebModel()).ToList();
            }
            retVal.DefaultLanguage = storeDto.DefaultLanguage != null ? new Language(storeDto.DefaultLanguage) : new Language("en-US");
            if(storeDto.Languages != null)
            {
                retVal.Languages = storeDto.Languages.Select(x => new Language(x)).ToList();
            }

            if (storeDto.Currencies != null)
            {
                retVal.Currencies.AddRange(storeDto.Currencies.Select(x => new Currency(Language.InvariantLanguage, x)));
            }
            retVal.DefaultCurrency = retVal.Currencies.FirstOrDefault(x => x.Equals(storeDto.DefaultCurrency));

            if (storeDto.DynamicProperties != null)
            {
                retVal.DynamicProperties = storeDto.DynamicProperties.Select(x => x.ToWebModel()).ToList();
                retVal.ThemeName = retVal.DynamicProperties.GetDynamicPropertyValue("DefaultThemeName");
            }

            return retVal;
        }
Пример #2
0
 public static Store ToWebModel(this VirtoCommerce.Client.Model.VirtoCommerceStoreModuleWebModelStore storeDto)
 {
     var retVal = new Store();
     retVal.InjectFrom(storeDto);
     if(storeDto.SeoInfos != null)
     {
         retVal.SeoInfos = storeDto.SeoInfos.Select(x => x.ToWebModel()).ToList();
     }
     retVal.DefaultLanguage = storeDto.DefaultLanguage != null ? new Language(storeDto.DefaultLanguage) : new Language("en-US");
     if(storeDto.Languages != null)
     {
         retVal.Languages = storeDto.Languages.Select(x => new Language(x)).ToList();
     }
     retVal.DefaultCurrency = Currency.Get(EnumUtility.SafeParse(storeDto.DefaultCurrency, CurrencyCodes.USD));
     if(storeDto.Currencies != null)
     {
         retVal.Currencies = storeDto.Currencies.Select(x => Currency.Get(EnumUtility.SafeParse(x, CurrencyCodes.USD))).ToList();
     }
     if(storeDto.DynamicProperties != null)
     {
         retVal.DynamicProperties = storeDto.DynamicProperties.Select(x => x.ToWebModel()).ToList();
         retVal.ThemeName = retVal.DynamicProperties.GetDynamicPropertyValue("DefaultThemeName");
     }
     
 
     return retVal;
 }
Пример #3
0
        public static Store ToWebModel(this VirtoCommerce.Client.Model.VirtoCommerceStoreModuleWebModelStore storeDto)
        {
            var retVal = new Store();
            retVal.InjectFrom<NullableAndEnumValueInjecter>(storeDto);
            if(!storeDto.SeoInfos.IsNullOrEmpty())
            {
                retVal.SeoInfos = storeDto.SeoInfos.Select(x => x.ToWebModel()).ToList();
            }
            retVal.DefaultLanguage = storeDto.DefaultLanguage != null ? new Language(storeDto.DefaultLanguage) : Language.InvariantLanguage;
            if(!storeDto.Languages.IsNullOrEmpty())
            {
                retVal.Languages = storeDto.Languages.Select(x => new Language(x)).ToList();
            }

            if (!storeDto.Currencies.IsNullOrEmpty())
            {
                retVal.Currencies.AddRange(storeDto.Currencies.Select(x => new Currency(Language.InvariantLanguage, x)));
            }
            retVal.DefaultCurrency = retVal.Currencies.FirstOrDefault(x => x.Equals(storeDto.DefaultCurrency));

            if (!storeDto.DynamicProperties.IsNullOrEmpty())
            {
                retVal.DynamicProperties = storeDto.DynamicProperties.Select(x => x.ToWebModel()).ToList();
                retVal.ThemeName = retVal.DynamicProperties.GetDynamicPropertyValue("DefaultThemeName");
            }
            if(!storeDto.DynamicProperties.IsNullOrEmpty())
            {
                retVal.Settings = storeDto.Settings.Select(x => x.ToWebModel()).ToList();
            }
            retVal.TrustedGroups = storeDto.TrustedGroups;
            retVal.StoreState = EnumUtility.SafeParse(storeDto.StoreState, StoreStatus.Open);

            return retVal;
        }