예제 #1
0
        /// <summary>
        ///     Set parameter values with provided product object
        /// </summary>
        /// <param name="p">Product information.</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public SingleProductViewModel(Product p, HotcakesApplication hccApp)
        {
            if (p == null)
            {
                throw new ArgumentNullException("Product");
            }
            if (hccApp == null)
            {
                throw new ArgumentNullException("HotcakesApplication");
            }

            UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales);
            Item      = p;

            ProductLink = UrlRewriter.BuildUrlForProduct(p);
            ImageUrls   = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, p);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp);

#pragma warning disable 0612, 0618
            ImageUrl = DiskStorage.ProductImageUrlSmall(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.IsCurrentRequestSecure());

            OriginalImageUrl = DiskStorage.ProductImageUrlOriginal(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
#pragma warning restore 0612, 0618
        }
예제 #2
0
 private void UpdateVariantImage(ProductValidateResponse validateResult, Product product, UserSpecificPrice price)
 {
     if (!string.IsNullOrEmpty(price.VariantId))
     {
         validateResult.MediumImageUrl = DiskStorage.ProductVariantImageUrlMedium(HccApp, product.Bvin,
                                                                                  product.ImageFileMedium, price.VariantId, false);
         validateResult.OriginalImageUrl = DiskStorage.ProductVariantImageUrlOriginal(HccApp, product.Bvin,
                                                                                      product.ImageFileMedium, price.VariantId, false);
     }
     else
     {
         validateResult.MediumImageUrl = DiskStorage.ProductImageUrlMedium(HccApp, product.Bvin,
                                                                           product.ImageFileMedium, false);
         validateResult.OriginalImageUrl = DiskStorage.ProductImageUrlOriginal(HccApp, product.Bvin,
                                                                               product.ImageFileMedium, false);
     }
 }
예제 #3
0
        /// <summary>
        ///     Load the Image information for the product
        /// </summary>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        /// <param name="product">Product for which its required to have the image details.</param>
        public void LoadProductImageUrls(HotcakesApplication hccApp, Product product)
        {
            OriginalUrl = DiskStorage.ProductImageUrlOriginal(hccApp, product.Bvin, product.ImageFileSmall,
                                                              hccApp.IsCurrentRequestSecure());
            MediumlUrl = DiskStorage.ProductImageUrlMedium(hccApp, product.Bvin, product.ImageFileMedium,
                                                           hccApp.IsCurrentRequestSecure());
            SmallUrl = DiskStorage.ProductImageUrlSmall(hccApp, product.Bvin, product.ImageFileSmall,
                                                        hccApp.IsCurrentRequestSecure());
            MediumlAltText = product.ImageFileMediumAlternateText;
            SmallAltText   = product.ImageFileSmallAlternateText;
            TinyUrl        = SmallUrl;

            if (string.IsNullOrWhiteSpace(MediumlAltText))
            {
                MediumlAltText = SmallAltText;
            }
        }