Exemplo n.º 1
0
 public static Product GetDisplayProduct(this Product product, bool skipStockAvailabilityCheck = true)
 {
     return(product.Variations == null || product.Variations.Product == null ||
            product.Variations.Product.Length == 0
         ? product
         : product.Variations.Product[0]);
 }
Exemplo n.º 2
0
        private ProductDetailPageViewModel GetDemoProduct()
        {
            SiteInfo si;

            WebSession.Current.TryGetSiteInfo(out si);
            var prod = new Product
            {
                Pricing          = new Pricing(),
                DisplayName      = "demo display name",
                ShortDescription = "demo",
                InventoryStatus  = new InventoryStatus()
            };
            var ret = new ProductDetailPageViewModel(si)
            {
                Product = prod, DisplayProduct = prod
            };

            return(ret);
        }
Exemplo n.º 3
0
 public static long GetParentProductId(this Product product)
 {
     if (product.BaseProduct)
     {
         return(product.Id);
     }
     if (product.ParentProduct != null)
     {
         // todo: 1st: why is this method needed in the first place? 2nd: we shouldn't have to parse the id out of the URI
         var idx = product.ParentProduct.Uri.LastIndexOf("/", StringComparison.Ordinal);
         if (idx <= 0)
         {
             return(0);
         }
         var  idstr = product.ParentProduct.Uri.Substring(idx + 1);
         long id;
         return(long.TryParse(idstr, out id) ? id : 0);
     }
     return(0);
 }
Exemplo n.º 4
0
 public static string GetParentTitle(this Product product)
 {
     return(product.DisplayName);
 }