/// <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
        }
Example #2
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;
            }
        }
Example #3
0
 public ProductPurchasedWithInfo(HotcakesApplication hccApp, Product product)
 {
     ImageUrl = DiskStorage.ProductImageUrlSmall(hccApp, product.Bvin, product.ImageFileSmall,
                                                 hccApp.IsCurrentRequestSecure());
     ProductId   = product.Bvin;
     ProductName = product.ProductName;
     UpdatedOn   = DateHelper.ConvertUtcToStoreTime(hccApp, product.LastUpdated).ToString("MMM dd, yyyy");
     CreatedOn   = DateHelper.ConvertUtcToStoreTime(hccApp, product.CreationDateUtc).ToString("MMM dd, yyyy");
 }
Example #4
0
        public SingleProductJsonModel(Product product, HotcakesApplication app)
        {
            ProductLink   = UrlRewriter.BuildUrlForProduct(product);
            ProductName   = product.ProductName;
            ImageSmallUrl = DiskStorage.ProductImageUrlSmall(app, product.Bvin, product.ImageFileSmall,
                                                             app.IsCurrentRequestSecure());
            ImageSmallAltText = product.ImageFileSmallAlternateText;
            ProductSku        = product.Sku;
            Bvin = product.Bvin;

            var up = app.PriceProduct(product, app.CurrentCustomer, null, app.CurrentlyActiveSales);

            UserPrice = up.DisplayPrice();
        }
Example #5
0
        public static string ReplaceContentTags(string source, HotcakesApplication app)
        {
            if (source.Contains("{{"))
            {
                var isSecureRequest = app.IsCurrentRequestSecure();
                var currentUserId   = app.CurrentCustomerId;

                var output = source;

                var r = RouteTable.Routes;

                output = output.Replace("{{homelink}}", app.StoreUrl(isSecureRequest, false));
                output = output.Replace("{{logo}}", HtmlRendering.Logo(app, isSecureRequest));
                output = output.Replace("{{logotext}}", HtmlRendering.LogoText(app));
                output = output.Replace("{{headerlinks}}", HtmlRendering.HeaderLinks(app, currentUserId));
                output = output.Replace("{{sitefiles}}", DiskStorage.GetStoreDataUrl(app, isSecureRequest));

                output = output.Replace("{{storeaddress}}",
                                        app.ContactServices.Addresses.FindStoreContactAddress().ToHtmlString());

                return(output);
            }
            return(source);
        }
Example #6
0
        /// <summary>
        ///     This method will iterate through the specified swatches and emit the requisite HTML for each
        /// </summary>
        /// <param name="p">Product - an instance of the product to find swatches for</param>
        /// <param name="app">HotcakesApplicateion - an instance of the current store application object</param>
        /// <returns>String - the HTML to be used for rendering the swatches</returns>
        /// <remarks>
        ///     If the swatch doesn't match an available swatch file, it will not be included in the HTML. Also, all swatch
        ///     images must be PNG or GIF.
        /// </remarks>
        public static string GenerateSwatchHtmlForProduct(Product p, HotcakesApplication app)
        {
            var result = string.Empty;

            if (app.CurrentStore.Settings.ProductEnableSwatches == false)
            {
                return(result);
            }

            if (p.Options.Count > 0)
            {
                var found = false;

                var swatchBase = DiskStorage.GetStoreDataUrl(app, app.IsCurrentRequestSecure());
                swatchBase += "swatches";
                if (p.SwatchPath.Length > 0)
                {
                    swatchBase += "/" + p.SwatchPath;
                }

                var swatchPhysicalBase = DiskStorage.GetStoreDataPhysicalPath(app.CurrentStore.Id);
                swatchPhysicalBase += "swatches\\";
                if (p.SwatchPath.Length > 0)
                {
                    swatchPhysicalBase += p.SwatchPath + "\\";
                }

                var sb = new StringBuilder();
                sb.Append("<div class=\"productswatches\">");
                foreach (var opt in p.Options)
                {
                    if (opt.IsColorSwatch)
                    {
                        found = true;
                        foreach (var oi in opt.Items)
                        {
                            if (oi.IsLabel)
                            {
                                continue;
                            }

                            var prefix = CleanSwatchName(oi.Name);

                            if (File.Exists(swatchPhysicalBase + prefix + ".png"))
                            {
                                sb.Append("<img width=\"18\" height=\"18\" src=\"" + swatchBase + "/" + prefix +
                                          ".png\" border=\"0\" alt=\"" + prefix + "\" />");
                            }
                            else
                            {
                                sb.Append("<img width=\"18\" height=\"18\" src=\"" + swatchBase + "/" + prefix +
                                          ".gif\" border=\"0\" alt=\"" + prefix + "\" />");
                            }
                        }
                    }
                }
                sb.Append("</div>");

                if (found)
                {
                    result = sb.ToString();
                }
            }

            return(result);
        }