public static Vendor ToVendor(this customerDto.Vendor vendorDto, Language currentLanguage, Store store)
        {
            Vendor result = null;

            if (vendorDto != null)
            {
                result = new Vendor
                {
                    Id          = vendorDto.Id,
                    Name        = vendorDto.Name,
                    Description = vendorDto.Description,
                    LogoUrl     = vendorDto.LogoUrl,
                    SiteUrl     = vendorDto.SiteUrl,
                    GroupName   = vendorDto.GroupName
                };

                if (!vendorDto.SeoInfos.IsNullOrEmpty())
                {
                    var seoInfoDto = vendorDto.SeoInfos.Select(x => x.JsonConvert <coreDto.SeoInfo>())
                                     .GetBestMatchingSeoInfos(store, currentLanguage)
                                     .FirstOrDefault();

                    if (seoInfoDto != null)
                    {
                        result.SeoInfo = seoInfoDto.ToSeoInfo();
                    }
                }

                if (result.SeoInfo == null)
                {
                    result.SeoInfo = new SeoInfo
                    {
                        Title = vendorDto.Name,
                        Slug  = string.Concat("/vendor/", result.Id)
                    };
                }

                if (vendorDto.Addresses != null)
                {
                    result.Addresses = vendorDto.Addresses.Select(ToAddress).ToList();
                }

                if (vendorDto.DynamicProperties != null)
                {
                    result.DynamicProperties = vendorDto.DynamicProperties.Select(ToDynamicProperty).ToList();
                }
            }

            return(result);
        }
Beispiel #2
0
        public virtual Vendor ToVendor(customerDto.Vendor vendorDto, Language currentLanguage, Store store)
        {
            Vendor result = null;

            if (vendorDto != null)
            {
                result             = ServiceLocator.Current.GetInstance <CustomerFactory>().CreateVendor();
                result.Id          = vendorDto.Id;
                result.Name        = vendorDto.Name;
                result.Description = vendorDto.Description;
                result.LogoUrl     = vendorDto.LogoUrl;
                result.SiteUrl     = vendorDto.SiteUrl;
                result.GroupName   = vendorDto.GroupName;

                if (!vendorDto.SeoInfos.IsNullOrEmpty())
                {
                    var seoInfoDto = vendorDto.SeoInfos.Select(x => x.JsonConvert <coreDto.SeoInfo>())
                                     .GetBestMatchingSeoInfos(store, currentLanguage)
                                     .FirstOrDefault();

                    if (seoInfoDto != null)
                    {
                        result.SeoInfo = seoInfoDto.ToSeoInfo();
                    }
                }

                if (result.SeoInfo == null)
                {
                    result.SeoInfo = new SeoInfo
                    {
                        Title = vendorDto.Name,
                        Slug  = string.Concat("/vendor/", result.Id)
                    };
                }

                if (vendorDto.Addresses != null)
                {
                    result.Addresses = vendorDto.Addresses.Select(ToAddress).ToList();
                }

                if (vendorDto.DynamicProperties != null)
                {
                    result.DynamicProperties = vendorDto.DynamicProperties.Select(ToDynamicProperty).ToList();
                }
            }

            return(result);
        }
Beispiel #3
0
 public static Vendor ToVendor(this customerDto.Vendor vendorDto, Language currentLanguage, Store store)
 {
     return(CustomerConverterInstance.ToVendor(vendorDto, currentLanguage, store));
 }