Esempio n. 1
0
        private static List <DWImage> ColorImages(List <ImageGroup> imageGroups, VariationAttributeValue colorVariation)
        {
            List <DWImage> colorImages = new List <DWImage>();

            try
            {
                if (imageGroups != null)
                {
                    colorImages = imageGroups.Where(z => z.VariationAttributes.Select(e => e.values.Where(v => v.value.Equals(colorVariation.Value)).Any()).FirstOrDefault() &&
                                                    z.ViewType == "hi-res" && z.Images.Any()).Select(z => z.Images).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                _staticerrors.Add(ex.Handle("Product.ColorImages", ErrorSeverity.FollowUp, ErrorType.RequestError));
                return(new List <DWImage>());
            }

            return(colorImages);
        }
Esempio n. 2
0
        private static List <SizeOption> DwSizeOptions(List <Variant> variants, VariationAttributeValue colorVariation, bool isOneSizeOnly, bool isGiftCard)
        {
            List <SizeOption> sizes;

            try
            {
                sizes = variants.Where(z => z.VariationValues
                                       .Any(a => a.Value.Equals(colorVariation.Value)))
                        .Select(z =>
                {
                    int sizeInt;
                    var sizeStr = string.Empty;
                    if (z.VariationValues.ContainsKey("size"))
                    {
                        sizeStr = z.VariationValues["size"];
                    }

                    int.TryParse(sizeStr, out sizeInt);

                    var width = string.Empty;
                    if (z.VariationValues.ContainsKey("width"))
                    {
                        width = z.VariationValues["width"];
                    }


                    var name = string.Empty;
                    if (isOneSizeOnly)
                    {
                        name = "One Size - ";
                    }
                    else if (!isGiftCard)
                    {
                        name = sizeInt != 0 ? string.Format("{0:N1} {1} - ", sizeInt / 10.0, width) : string.Format("{0} {1} - ", sizeStr, width);
                    }


                    var shortName = name.Replace(" - ", string.Empty);
                    name          = string.Format("{0}${1}{2}", name, z.Price,
                                                  z.IsOrderable ? string.Empty : " (Out of Stock)");

                    var sizeLabel = string.Format("{0:N1}", sizeInt / 10.0);
                    return(new SizeOption
                    {
                        Name = name,
                        ShortName = shortName,
                        Value = z.ProductId,
                        IsInStock = z.IsOrderable,
                        SizeLabel = sizeLabel,
                        WidthLabel = width,
                        Price = "$" + z.Price.ToString()
                    });
                })
                        .ToList();
            }
            catch (Exception ex)
            {
                _staticerrors.Add(ex.Handle("Product.DWSizeOptions", ErrorSeverity.FollowUp, ErrorType.RequestError));
                return(new List <SizeOption>());
            }

            return(sizes);
        }