当前位置: 首页>>代码示例>>C#>>正文


C# IPictureService.GetPicturesByProductId方法代码示例

本文整理汇总了C#中IPictureService.GetPicturesByProductId方法的典型用法代码示例。如果您正苦于以下问题:C# IPictureService.GetPicturesByProductId方法的具体用法?C# IPictureService.GetPicturesByProductId怎么用?C# IPictureService.GetPicturesByProductId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPictureService的用法示例。


在下文中一共展示了IPictureService.GetPicturesByProductId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrepareCategoryViewModels

        public static IList<CategoryView> PrepareCategoryViewModels(this IList<Category> categories, 
            IPictureService pictureService, SystemSetting sysSetting, int? pictureSize = null)
        {
            IList<CategoryView> results = new List<CategoryView>();

            foreach (var item in categories)
            {
                CategoryView view = new CategoryView
                {
                    Id = item.Id,
                    Name = item.Name
                };

                // Prepare the picture model
                if (pictureSize.HasValue && pictureService != null && sysSetting != null)
                {
                    //picture
                    var picture = pictureService.GetPicturesByProductId(item.Id, 1).FirstOrDefault();
                    int imageSize = pictureSize > 0 ? pictureSize.Value : sysSetting.DefaultThumbPicSize;

                    // PictureModel
                    PictureModel pictureModel = new PictureModel
                    {
                        ImageUrl = pictureService.GetPictureUrl(picture, imageSize),
                        FullSizeImageUrl = pictureService.GetPictureUrl(picture),
                        Title = string.Format("Show detail for {0}", item.Name),
                        AlternateText = string.Format("Image of {0}", item.Name)
                    };
                    view.PictureModel = pictureModel;
                }
                results.Add(view);
            }
            return results;
        }
开发者ID:yubowave,项目名称:bongstore,代码行数:34,代码来源:ViewModelExtensions.cs

示例2: GetProductPicture

        /// <summary>
        /// Get product picture (for shopping cart and order details pages)
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Atributes (in XML format)</param>
        /// <param name="pictureService">Picture service</param>
        /// <param name="productAttributeParser">Product attribute service</param>
        /// <returns>Picture</returns>
        public static Picture GetProductPicture(this Product product, string attributesXml,
            IPictureService pictureService,
            IProductAttributeParser productAttributeParser)
        {
            if (product == null)
                throw new ArgumentNullException("product");
            if (pictureService == null)
                throw new ArgumentNullException("pictureService");
            if (productAttributeParser == null)
                throw new ArgumentNullException("productAttributeParser");

            Picture picture = null;

            //first, let's see whether we have some attribute values with custom pictures
            var attributeValues = productAttributeParser.ParseProductAttributeValues(attributesXml);
            foreach (var attributeValue in attributeValues)
            {
                var attributePicture = pictureService.GetPictureById(attributeValue.PictureId);
                if (attributePicture != null)
                {
                    picture = attributePicture;
                    break;
                }
            }

            //now let's load the default product picture
            if (picture == null)
            {
                picture = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
            }

            //let's check whether this product has some parent "grouped" product
            if (picture == null && !product.VisibleIndividually && product.ParentGroupedProductId > 0)
            {
                picture = pictureService.GetPicturesByProductId(product.ParentGroupedProductId, 1).FirstOrDefault();
            }

            return picture;
        }
开发者ID:nvolpe,项目名称:raver,代码行数:47,代码来源:Extensions.cs

示例3: PrepareProductViewModels

        /// <summary>
        /// 
        /// </summary>
        /// <param name="products"></param>
        /// <param name="pictureService"></param>
        /// <param name="sysSetting"></param>
        /// <param name="pictureSize">if null, don't load picture</param>
        /// <returns></returns>
        public static IList<ProductViewModel> PrepareProductViewModels(this IList<Product> products, IPictureService pictureService,
            SystemSetting sysSetting, int? pictureSize = null)
        {
            IList<ProductViewModel> results = new List<ProductViewModel>();

            foreach (var product in products)
            {
                ProductViewModel model = new ProductViewModel
                {
                    Id = product.Id,
                    Name = product.Name,
                    ShortDescription = product.ShortDescription,
                    Description = product.ShortDescription,
                    Price = product.Price,
                    RatingSum = product.RatingSum,
                    TotalReviews = product.TotalReviews
                };

                if (pictureSize.HasValue && pictureService != null && sysSetting != null)
                {
                    //picture
                    var picture = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
                    int imageSize = pictureSize > 0 ? pictureSize.Value : sysSetting.DefaultThumbPicSize;

                    // PictureModel
                    PictureModel pictureModel = new PictureModel
                    {
                        ImageUrl = pictureService.GetPictureUrl(picture, imageSize),
                        FullSizeImageUrl = pictureService.GetPictureUrl(picture),
                        Title = string.Format("Show detail for {0}", product.Name),
                        AlternateText = string.Format("Image of {0}", product.Name)
                    };
                    model.PictureModel = pictureModel;
                }
                results.Add(model);
            }
            return results;
        }
开发者ID:yubowave,项目名称:bongstore,代码行数:46,代码来源:ViewModelExtensions.cs

示例4: GetAssignedPicture

		public static Picture GetAssignedPicture(this ProductDetailsModel model, IPictureService pictureService, IList<Picture> pictures, int productId = 0)
		{
			if (model != null && model.CombinationSelected != null)
			{
				Picture picture = null;
				var combiAssignedImages = model.CombinationSelected.GetAssignedPictureIds();

				if (combiAssignedImages.Length > 0)
				{
					if (pictures == null)
						picture = pictureService.GetPictureById(combiAssignedImages[0]);
					else
						picture = pictures.FirstOrDefault(p => p.Id == combiAssignedImages[0]);
				}

				if (picture == null && productId != 0)
				{
					picture = pictureService.GetPicturesByProductId(productId, 1).FirstOrDefault();
				}
				return picture;
			}
			return null;
		}
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:23,代码来源:ProductDetailsExtensions.cs

示例5: PrepareProductOverviewModels


//.........这里部分代码省略.........
                                                priceModel.Price = String.Format(localizationService.GetResource("Products.PriceRangeFrom"), priceFormatter.FormatPrice(finalPrice));
                                            }
                                            else
                                            {
                                                if (finalPriceBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                                {
                                                    priceModel.OldPrice = priceFormatter.FormatPrice(oldPrice);
                                                    priceModel.Price = priceFormatter.FormatPrice(finalPrice);
                                                }
                                                else
                                                {
                                                    priceModel.OldPrice = null;
                                                    priceModel.Price = priceFormatter.FormatPrice(finalPrice);
                                                }
                                            }
                                            if (product.IsRental)
                                            {
                                                //rental product
                                                priceModel.OldPrice = priceFormatter.FormatRentalProductPeriod(product, priceModel.OldPrice);
                                                priceModel.Price = priceFormatter.FormatRentalProductPeriod(product, priceModel.Price);
                                            }

                                            //property for German market
                                            //we display tax/shipping info only with "shipping enabled" for this product
                                            //we also ensure this it's not free shipping
                                            priceModel.DisplayTaxShippingInfo = catalogSettings.DisplayTaxShippingInfoProductBoxes
                                                && product.IsShipEnabled &&
                                                !product.IsFreeShipping;
                                        }
                                    }
                                }
                                else
                                {
                                    //hide prices
                                    priceModel.OldPrice = null;
                                    priceModel.Price = null;
                                }

                                #endregion
                            }
                            break;
                    }

                    model.ProductPrice = priceModel;

                    #endregion
                }

                //picture
                if (preparePictureModel)
                {
                    #region Prepare product picture

                    //If a size has been set in the view, we use it in priority
                    int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : mediaSettings.ProductThumbPictureSize;
                    //prepare picture model
                    var defaultProductPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, product.Id, pictureSize, true, workContext.WorkingLanguage.Id, webHelper.IsCurrentConnectionSecured(), storeContext.CurrentStore.Id);
                    model.DefaultPictureModel = cacheManager.Get(defaultProductPictureCacheKey, () =>
                    {
                        var picture = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
                        var pictureModel = new PictureModel
                        {
                            ImageUrl = pictureService.GetPictureUrl(picture, pictureSize),
                            FullSizeImageUrl = pictureService.GetPictureUrl(picture)
                        };
                        //"title" attribute
                        pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.TitleAttribute)) ?
                            picture.TitleAttribute :
                            string.Format(localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
                        //"alt" attribute
                        pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.AltAttribute)) ?
                            picture.AltAttribute :
                            string.Format(localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);

                        return pictureModel;
                    });

                    #endregion
                }

                //specs
                if (prepareSpecificationAttributes)
                {
                    model.SpecificationAttributeModels = PrepareProductSpecificationModel(controller, workContext,
                         specificationAttributeService, cacheManager, product);
                }

                //reviews
                model.ReviewOverviewModel = new ProductReviewOverviewModel
                {
                    ProductId = product.Id,
                    RatingSum = product.ApprovedRatingSum,
                    TotalReviews = product.ApprovedTotalReviews,
                    AllowCustomerReviews = product.AllowCustomerReviews
                };

                models.Add(model);
            }
            return models;
        }
开发者ID:rajendra1809,项目名称:nopCommerce,代码行数:101,代码来源:ControllerExtensions.cs

示例6: GetDefaultProductPicture

        /// <summary>
        /// Get a default picture of a product 
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="pictureService">Picture service</param>
        /// <returns>Product picture</returns>
        public static Picture GetDefaultProductPicture(this Product source, IPictureService pictureService)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            if (pictureService == null)
                throw new ArgumentNullException("pictureService");

            var picture = pictureService.GetPicturesByProductId(source.Id, 1).FirstOrDefault();
            return picture;
        }
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:17,代码来源:ProductExtensions.cs

示例7: PrepareProductOverviewModels

        public IEnumerable<ProductOverviewModel> PrepareProductOverviewModels(
            IWorkContext workContext,
            IStoreContext storeContext,
            IProductService productService,
            ILocalizationService localizationService,
            IPictureService pictureService,
            IWebHelper webHelper,
            ICacheManager cacheManager,
            CatalogSettings catalogSettings,
            MediaSettings mediaSettings,
            IEnumerable<Product> products,
            int? productThumbPictureSize = null)
        {
            if (products == null)
                throw new ArgumentNullException("products");

            var models = new List<ProductOverviewModel>();
            foreach (var product in products)
            {
                var model = new ProductOverviewModel
                {
                    Id = product.Id,
                    Name = product.GetLocalized(x => x.Name),
                    ShortDescription = product.GetLocalized(x => x.ShortDescription),
                    FullDescription = product.GetLocalized(x => x.FullDescription),
                    SeName = product.GetSeName(),
                };

                //picture
                #region Prepare product picture

                //If a size has been set in the view, we use it in priority
                int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : mediaSettings.ProductThumbPictureSize;
                //prepare picture model
                var defaultProductPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, product.Id, pictureSize, true, workContext.WorkingLanguage.Id, webHelper.IsCurrentConnectionSecured(), storeContext.CurrentStore.Id);
                model.DefaultPictureModel = cacheManager.Get(defaultProductPictureCacheKey, () =>
                {
                    var picture = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
                    var pictureModel = new PictureModel
                    {
                        ImageUrl = pictureService.GetPictureUrl(picture, pictureSize),
                        FullSizeImageUrl = pictureService.GetPictureUrl(picture)
                    };
                    //"title" attribute
                    pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.TitleAttribute)) ?
                        picture.TitleAttribute :
                        string.Format(localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
                    //"alt" attribute
                    pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.AltAttribute)) ?
                        picture.AltAttribute :
                        string.Format(localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);

                    return pictureModel;
                });

                #endregion

                models.Add(model);
            }
            return models;
        }
开发者ID:phatnguyen81,项目名称:NakeDearThorganics,代码行数:61,代码来源:WidgetsCustomBestSellerController.cs


注:本文中的IPictureService.GetPicturesByProductId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。