Esempio n. 1
0
        public static Link ToShopfiyModel(this StorefrontModel.MenuLink storefrontModel, Storefront.Model.WorkContext workContext, IStorefrontUrlBuilder urlBuilder)
        {
            var shopifyModel = new Link();

            shopifyModel.Active = storefrontModel.IsActive;
            shopifyModel.Object = "";
            shopifyModel.Title  = storefrontModel.Title;
            shopifyModel.Type   = "";
            shopifyModel.Url    = urlBuilder.ToAppAbsolute(storefrontModel.Url);

            var productLink  = storefrontModel as StorefrontModel.ProductMenuLink;
            var categoryLink = storefrontModel as StorefrontModel.CategoryMenuLink;

            if (productLink != null)
            {
                shopifyModel.Type = "product";
                if (productLink.Product != null)
                {
                    shopifyModel.Object = productLink.Product.ToShopifyModel();
                }
            }
            if (categoryLink != null)
            {
                shopifyModel.Type = "collection";
                if (categoryLink.Category != null)
                {
                    shopifyModel.Object = categoryLink.Category.ToShopifyModel(workContext);
                }
            }
            return(shopifyModel);
        }
        public virtual Link ToLiquidLink(StorefrontModel.MenuLink link, Storefront.Model.WorkContext workContext, IStorefrontUrlBuilder urlBuilder)
        {
            var factory = ServiceLocator.Current.GetInstance <ShopifyModelFactory>();
            var result  = factory.CreateLink();

            result.InjectFrom <StorefrontModel.Common.NullableAndEnumValueInjecter>(link);

            result.Object = "";
            result.Title  = link.Title;
            result.Type   = "";
            result.Url    = urlBuilder.ToAppAbsolute(link.Url);

            var productLink  = link as StorefrontModel.ProductMenuLink;
            var categoryLink = link as StorefrontModel.CategoryMenuLink;

            if (productLink != null)
            {
                result.Type = "product";
                if (productLink.Product != null)
                {
                    result.Object = productLink.Product.ToShopifyModel();
                }
            }
            if (categoryLink != null)
            {
                result.Type = "collection";
                if (categoryLink.Category != null)
                {
                    result.Object = categoryLink.Category.ToShopifyModel(workContext);
                }
            }
            return(result);
        }
        public virtual Link ToLiquidLink(StorefrontModel.MenuLink link, Storefront.Model.WorkContext workContext, IStorefrontUrlBuilder urlBuilder)
        {
            var result = new Link();

            result.Object = "";
            result.Title  = link.Title;
            result.Type   = "";
            result.Url    = urlBuilder.ToAppAbsolute(link.Url);

            var productLink  = link as StorefrontModel.ProductMenuLink;
            var categoryLink = link as StorefrontModel.CategoryMenuLink;

            if (productLink != null)
            {
                result.Type = "product";
                if (productLink.Product != null)
                {
                    result.Object = productLink.Product.ToShopifyModel();
                }
            }
            if (categoryLink != null)
            {
                result.Type = "collection";
                if (categoryLink.Category != null)
                {
                    result.Object = categoryLink.Category.ToShopifyModel(workContext);
                }
            }
            return(result);
        }
        public static Link ToShopfiyModel(this StorefrontModel.MenuLink storefrontModel)
        {
            var shopifyModel = new Link();

            shopifyModel.Active = storefrontModel.IsActive;
            shopifyModel.Object = "";
            shopifyModel.Title  = storefrontModel.Title;
            shopifyModel.Type   = "";
            shopifyModel.Url    = storefrontModel.Url;

            return(shopifyModel);
        }
        public static MenuLink ToWebModel(this VirtoCommerceContentWebModelsMenuLink serviceModel, IStorefrontUrlBuilder urlBuilder)
        {
            var webModel = new MenuLink();

            webModel.InjectFrom(serviceModel);

            if (serviceModel.SecurityScopes != null)
            {
                webModel.SecurityScopes = serviceModel.SecurityScopes.Select(ss => ss).ToList();
            }

            webModel.Url = urlBuilder.ToAppAbsolute("/" + serviceModel.Url);

            return webModel;
        }
        public static Link ToShopfiyModel(this StorefrontModel.MenuLink link, Storefront.Model.WorkContext workContext, IStorefrontUrlBuilder urlBuilder)
        {
            var converter = ServiceLocator.Current.GetInstance <ShopifyModelConverter>();

            return(converter.ToLiquidLink(link, workContext, urlBuilder));
        }
        public static Link ToShopfiyModel(this StorefrontModel.MenuLink link, Storefront.Model.WorkContext workContext, IStorefrontUrlBuilder urlBuilder)
        {
            var converter = new ShopifyModelConverter();

            return(converter.ToLiquidLink(link, workContext, urlBuilder));
        }