November Happy Hour will be moved to Thursday December 5th.

Class AffectedEntries

Used for handling redemption calculations on entry promotions.

Inheritance
System.Object
AffectedEntries
Implements
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Marketing
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0
Syntax
public class AffectedEntries : IAffectedObject
Remarks

An example of typical usage of this class:

You have a "Buy 3 pay for 2" type of discount. The AffectedEntries would be filled with a quantity of three (corresponding to the "Buy 3" part), and you would call SetDiscountRange with parameters 2, 1 to indicate that the discount would be applied to the last item (skip 2 and apply to the final single quantity).

Note that setting a discount range and iterating over that range might mean that the configuration of the underlying list might change, since individual price entries might be split to support the requests. There is even support for having fractional quantities.

Constructors

AffectedEntries(AffectedEntries)

Initializes a new instance of a AffectedEntries that is a copy of original.

Declaration
public AffectedEntries(AffectedEntries original)
Parameters
Type Name Description
AffectedEntries original

The instance to copy.

AffectedEntries(IList<PriceEntry>)

Initializes a new instance of a AffectedEntries.

Declaration
public AffectedEntries(IList<PriceEntry> priceEntries)
Parameters
Type Name Description
System.Collections.Generic.IList<PriceEntry> priceEntries

The price entries.

Properties

BatchId

Identifier to track this specific instance.

Declaration
public Guid BatchId { get; }
Property Value
Type Description
System.Guid

PriceEntries

Gets the price entries

Declaration
public IEnumerable<PriceEntry> PriceEntries { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<PriceEntry>

Quantity

The total quantity of entries in this instance.

Declaration
public decimal Quantity { get; }
Property Value
Type Description
System.Decimal

Methods

DiscountRange()

Gets the subset range of this instance based on values set in SetDiscountRange(Decimal, Decimal)

Declaration
public IEnumerable<PriceEntry> DiscountRange()
Returns
Type Description
System.Collections.Generic.IEnumerable<PriceEntry>

An System.Collections.Generic.IEnumerable<T> that can be used to iterate over the contained PriceEntries.

ForEachCode<T>(Func<PriceEntry, T, T>)

Enumerates over all entries in the current discount range and performs calculation per entry code.

Declaration
public IDictionary<string, T> ForEachCode<T>(Func<PriceEntry, T, T> calculation)
Parameters
Type Name Description
System.Func<PriceEntry, T, T> calculation

The actual calculation to perform. Takes a PriceEntry and an accumulator and returns the accumulator together with the new value.

Returns
Type Description
System.Collections.Generic.IDictionary<System.String, T>

A Dictionary that contains the code as key and the final result of the calculation as value.

Type Parameters
Name Description
T

The resulting type of the calculation, usually decimal if summing up values.

Remarks

Note that the iteration is done over the current discount range, which is usually the only interesting part. If you need to iterate over the entire range of entries, reset by calling SetDiscountRange(0, 0).

SavedAmountPerCode()

Gets information about the saved amount per code.

Declaration
public IDictionary<string, decimal> SavedAmountPerCode()
Returns
Type Description
System.Collections.Generic.IDictionary<System.String, System.Decimal>

A Dictionary that contains the code as key and the saved amount as value.

Remarks

Note that the iteration is done over the current discount range.

SetDiscountRange(Decimal, Decimal)

Set the range on this instance that will have actual discounting applied to it.

Declaration
public AffectedEntries SetDiscountRange(decimal skip, decimal quantity)
Parameters
Type Name Description
System.Decimal skip

The amount of quantity to skip from the beginning of the list.

System.Decimal quantity

The quantity to actually use when applying discounts.

Returns
Type Description
AffectedEntries

This instance.

Remarks

You can reset the discount range by calling this method with both parameters set to 0.

ShallowCopy()

Creates a shallow copy of the instance.

Declaration
protected AffectedEntries ShallowCopy()
Returns
Type Description
AffectedEntries

Explicit Interface Implementations

IAffectedObject.SavedAmount

The saved amount.

Declaration
decimal IAffectedObject.SavedAmount { get; set; }
Returns
Type Description
System.Decimal

Implements