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


C# IPictureService.GetPictureUrl方法代码示例

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


在下文中一共展示了IPictureService.GetPictureUrl方法的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: 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

示例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: 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

示例5: ToListModel

 public static VendorReviewListModel ToListModel(this VendorReview Review,IPictureService _pictureService, Product Product, Vendor Vendor, Order Order)
 {
     
     var model = new VendorReviewListModel()
     {
         CreatedOnUTC = Review.CreatedOnUTC,
         CustomerId = Review.CustomerId,
         HelpfulnessNoTotal = Review.HelpfulnessNoTotal,
         HelpfulnessYesTotal = Review.HelpfulnessYesTotal,
         Id = Review.Id,
         IsApproved = Review.IsApproved,
         ProductId = Review.ProductId,
         Rating = Review.Rating,
         ReviewText = Review.ReviewText,
         Title = Review.Title,
         VendorId = Review.VendorId,    
         OrderId = Review.OrderId,
         CertifiedBuyerReview = Review.CertifiedBuyerReview,
         DisplayCertifiedBadge = Review.DisplayCertifiedBadge,
     };
      if (Product != null)
     {
         model.ProductName = Product.Name;
         model.ProductSeName = Product.GetSeName();
         model.ProductImageUrl = _pictureService.GetPictureUrl(Product.ProductPictures.FirstOrDefault().Picture);
         
     }
     if (Vendor != null)
     {
         model.VendorName = Vendor.Name;
         model.VendorSeName = Vendor.GetSeName();
     }
     return model;
 }
开发者ID:RoastedBytes,项目名称:NopCommerceExtendedVendor,代码行数:34,代码来源:Helpers.cs

示例6: ToModel

        public static ProductReviewListModel ToModel(this ProductReview ProductReview, IPictureService _pictureService)
        {
            var model = new ProductReviewListModel() {
                CustomerId = ProductReview.CustomerId,
                ProductId = ProductReview.ProductId,
                ProductName = ProductReview.Product.Name,
                Rating = ProductReview.Rating,
                ReviewText = ProductReview.ReviewText,
                ProductSeName = ProductReview.Product.GetSeName(),
                ProductImageUrl = _pictureService.GetPictureUrl(ProductReview.Product.ProductPictures.FirstOrDefault().Picture),
                Title = ProductReview.Title,
                CreatedOnUtc = ProductReview.CreatedOnUtc

            };
            return model;
        }
开发者ID:RoastedBytes,项目名称:NopCommerceExtendedVendor,代码行数:16,代码来源:Helpers.cs

示例7: GetPictureUrl

        public static string GetPictureUrl(int pictureId, ICacheManager _cacheManager, IPictureService _pictureService)
        {
            string cacheKey = string.Format("APEXOL-VENDOR-PICTURE-{0}", pictureId);
            return _cacheManager.Get(cacheKey, () =>
            {
                var url = _pictureService.GetPictureUrl(pictureId, showDefaultPicture: false);
                //little hack here. nulls aren't cacheable so set it to ""
                if (url == null)
                    url = "";

                return url;
            });
        }
开发者ID:RoastedBytes,项目名称:NopCommerceExtendedVendor,代码行数:13,代码来源:Helpers.cs


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