本文整理汇总了C#中IPermissionService.Authorize方法的典型用法代码示例。如果您正苦于以下问题:C# IPermissionService.Authorize方法的具体用法?C# IPermissionService.Authorize怎么用?C# IPermissionService.Authorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPermissionService
的用法示例。
在下文中一共展示了IPermissionService.Authorize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareProductOverviewModels
public static IEnumerable<ProductOverviewModel> PrepareProductOverviewModels(this Controller controller,
IWorkContext workContext,
IStoreContext storeContext,
ICategoryService categoryService,
IProductService productService,
ISpecificationAttributeService specificationAttributeService,
IPriceCalculationService priceCalculationService,
IPriceFormatter priceFormatter,
IPermissionService permissionService,
ILocalizationService localizationService,
ITaxService taxService,
ICurrencyService currencyService,
IPictureService pictureService,
IWebHelper webHelper,
ICacheManager cacheManager,
CatalogSettings catalogSettings,
MediaSettings mediaSettings,
IEnumerable<Product> products,
bool preparePriceModel = true, bool preparePictureModel = true,
int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
bool forceRedirectionAfterAddingToCart = false)
{
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(),
};
//price
if (preparePriceModel)
{
#region Prepare product price
var priceModel = new ProductOverviewModel.ProductPriceModel
{
ForceRedirectionAfterAddingToCart = forceRedirectionAfterAddingToCart
};
switch (product.ProductType)
{
case ProductType.GroupedProduct:
{
#region Grouped product
var associatedProducts = productService.GetAssociatedProducts(product.Id, storeContext.CurrentStore.Id);
switch (associatedProducts.Count)
{
case 0:
{
//no associated products
//priceModel.DisableBuyButton = true;
//priceModel.DisableWishlistButton = true;
//compare products
priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
//priceModel.AvailableForPreOrder = false;
}
break;
default:
{
//we have at least one associated product
//priceModel.DisableBuyButton = true;
//priceModel.DisableWishlistButton = true;
//compare products
priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
//priceModel.AvailableForPreOrder = false;
if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
{
//find a minimum possible price
decimal? minPossiblePrice = null;
Product minPriceProduct = null;
foreach (var associatedProduct in associatedProducts)
{
//calculate for the maximum quantity (in case if we have tier prices)
var tmpPrice = priceCalculationService.GetFinalPrice(associatedProduct,
workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
{
minPriceProduct = associatedProduct;
minPossiblePrice = tmpPrice;
}
}
if (minPriceProduct != null && !minPriceProduct.CustomerEntersPrice)
{
if (minPriceProduct.CallForPrice)
{
priceModel.OldPrice = null;
priceModel.Price = localizationService.GetResource("Products.CallForPrice");
}
else if (minPossiblePrice.HasValue)
{
//.........这里部分代码省略.........