本文整理汇总了C#中Catalog.GetPrice方法的典型用法代码示例。如果您正苦于以下问题:C# Catalog.GetPrice方法的具体用法?C# Catalog.GetPrice怎么用?C# Catalog.GetPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog.GetPrice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatalogData
public CatalogData(
IApplicationConfiguration configuration,
Catalog catalog,
Product[] products)
{
// set the root category
Categories = new Category
{
Key = new string[] {"catalog"},
Slug = "catalog",
Name = "Catalog",
Products = new List<CatalogProduct>(products.Length),
};
// convert products
Products = new Dictionary<string, CatalogProduct>(products.Length);
foreach (var p in products)
{
// find/build the category
var category = Categories;
for (int i = 1; i < p.Category.Length; i++)
{
var slug = p.Category[i].ToSlug();
if (null == category.Children)
{
category.Children = new Dictionary<string, Category>();
}
if (!category.Children.ContainsKey(slug))
{
category.Children[slug] = new Category
{
Key = category.Key.Concat(new[] {slug}).ToArray(),
Name = p.Category[i],
Parent = category,
Slug = slug,
Products = new List<CatalogProduct>(100),
};
}
category = category.Children[slug];
}
// tranform the product
var x = new CatalogProduct
{
Catalog = catalog,
Id = p.ProductId,
Name = p.Name,
Sku = p.Sku,
Manufacturer = p.Manufacturer,
Brand = p.Brand,
Model = p.Model,
Description = p.Description,
Features = p.Features,
Warranty = p.Warranty,
CountryOfOrigin = p.CountryOfOrigin,
Category = category,
Tags = p.Tags,
Price = (int)Math.Ceiling(catalog.GetPrice(p) * configuration.PointsPerDollar),
Options = null == p.Options
? new List<CatalogProductOption>()
: p.Options.Select(i => {
var source = i.GetBestSource();
var price = null == source ? null : source.Pricing;
return new CatalogProductOption
{
Sku = i.Sku,
Name = i.Name,
Price = price == null ? null : (int?)Math.Ceiling(configuration.PointsPerDollar * catalog.GetPrice(p, i.Name)),
};
}).ToList(),
};
Products[x.Id] = x;
// add to various categories
do
{
category.Products.Add(x);
category = category.Parent;
} while (category != null);
}
}