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


C# Catalog.GetPrice方法代码示例

本文整理汇总了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);
            }

        }
开发者ID:nicknystrom,项目名称:AscendRewards,代码行数:83,代码来源:ICatalogService.cs


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