本文整理汇总了C#中Order.ItemsWithProduct方法的典型用法代码示例。如果您正苦于以下问题:C# Order.ItemsWithProduct方法的具体用法?C# Order.ItemsWithProduct怎么用?C# Order.ItemsWithProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.ItemsWithProduct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override void Apply(Order order)
{
var numberOfApplicableBundles = BaseProducts
.Select(b => Convert.ToInt32(order.ProductQuantity(b.Product) / b.Quantity))
.Min();
foreach (var addition in AdditionProducts)
{
var actualQuantity = order.ProductQuantity(addition.Product);
if (actualQuantity == 0) continue;
var applicableQuantity = numberOfApplicableBundles * addition.Quantity;
//
// number of addition products in order can be bigger or lesser
// than according to number of applicable items
//
var adjustmentQuantity = Math.Min(actualQuantity, applicableQuantity);
string item = string.Format(
"{0}% off on '{1}' (bundle {2})",
addition.PercentOff, addition.Product, GetShortBundleDescr());
decimal price = order.ItemsWithProduct(addition.Product).First().PricePerUnit;
order.AddItem(item).Quantity(adjustmentQuantity)
.PricePerUnit(-price * addition.PercentOff / 100);
}
}
示例2: Apply
public override void Apply(Order order)
{
var affectedItems = order.ItemsWithProduct(Product);
var adjustmentItems = affectedItems.Select(CreateAdjustmentItem);
foreach (var newItem in adjustmentItems)
{
order.AddItem(newItem);
}
}
示例3: Apply
public override void Apply(Order order)
{
var desiredItems = order.ItemsWithProduct(Product).ToArray();
if (!desiredItems.Any()) return;
var regularPrice = desiredItems.First().PricePerUnit;
var sumOfDesiredItems = desiredItems.Sum(i => i.Quantity);
int wholeGroupsCount = Convert.ToInt32(sumOfDesiredItems/NumberInGroup);
string item = string.Format(
"Bulk discount on '{0}' groups of {1} ({2} whole groups)",
Product, NumberInGroup, wholeGroupsCount);
order.AddItem(item).Quantity(wholeGroupsCount)
.PricePerUnit((SpecialPrice - regularPrice)*wholeGroupsCount*NumberInGroup);
}