Class RulesContext
The context object that will be passed to the Rules Engine. Provides way to do intellisense rules creation. Class can also be extended with custom functionality if needed, as well as functions that might be useful during rules creation.
Inheritance
Inherited Members
Namespace: Mediachase.Commerce.Marketing.Validators
Assembly: Mediachase.Commerce.Marketing.Validators.dll
Version: 10.8.0Syntax
public class RulesContext
Constructors
RulesContext(IDictionary<String, Object>)
Initializes a new instance of the RulesContext class.
Declaration
public RulesContext(IDictionary<string, object> context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Object> | context | The context. |
Properties
Context
Gets the context.
Declaration
public IDictionary<string, object> Context { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Object> | The context. |
CurrentCustomerContact
Gets the customer account.
Declaration
public CustomerContact CurrentCustomerContact { get; }
Property Value
| Type | Description |
|---|---|
| CustomerContact | The customer account. |
CustomerProfile
Gets the customer profile.
Declaration
public CustomerProfileWrapper CustomerProfile { get; }
Property Value
| Type | Description |
|---|---|
| CustomerProfileWrapper | The customer profile. |
Orders
Gets the orders.
Declaration
public PurchaseOrder[] Orders { get; }
Property Value
| Type | Description |
|---|---|
| PurchaseOrder[] | The orders. |
PromotionContext
Gets the promotion context.
Declaration
public PromotionContext PromotionContext { get; }
Property Value
| Type | Description |
|---|---|
| PromotionContext | The promotion context. |
PromotionCurrentOrderForm
Gets the promotion current order form.
Declaration
public OrderForm PromotionCurrentOrderForm { get; }
Property Value
| Type | Description |
|---|---|
| OrderForm | The promotion current order form. |
PromotionCurrentShipment
Gets the promotion current shipment.
Declaration
public Shipment PromotionCurrentShipment { get; }
Property Value
| Type | Description |
|---|---|
| Shipment | The promotion current shipment. |
PromotionOrderFormBillingAddress
Gets the promotion order form billing address.
Declaration
public OrderAddress PromotionOrderFormBillingAddress { get; }
Property Value
| Type | Description |
|---|---|
| OrderAddress | The promotion order form billing address. |
PromotionTargetLineItem
Gets the promotion target line item.
Declaration
public PromotionEntry PromotionTargetLineItem { get; }
Property Value
| Type | Description |
|---|---|
| PromotionEntry | The promotion target line item. |
RuntimeContext
Runtime context which can be used to store variables in the rules engine.
Declaration
public Hashtable RuntimeContext { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Hashtable | The runtime context. |
ShoppingCart
Gets the shopping cart.
Declaration
public OrderGroup ShoppingCart { get; }
Property Value
| Type | Description |
|---|---|
| OrderGroup | The shopping cart. |
ValidationResult
Gets or sets the validation result.
Declaration
public ValidationResult ValidationResult { get; set; }
Property Value
| Type | Description |
|---|---|
| ValidationResult | The validation result. |
Methods
AddFreeGiftToCart(String, String[])
Adds the free gift to cart.
Declaration
public void AddFreeGiftToCart(string quantity, params string[] entryCodes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | quantity | The quantity. |
| System.String[] | entryCodes | The entry codes. |
Remarks
This method using in promotion actions rulset
AddPromotionItemRecord(PromotionItemRecord)
Adds the promotion item record.
Declaration
public PromotionItemRecord AddPromotionItemRecord(PromotionItemRecord record)
Parameters
| Type | Name | Description |
|---|---|---|
| PromotionItemRecord | record | The record. |
Returns
| Type | Description |
|---|---|
| PromotionItemRecord |
AddPromotionItemRecord(PromotionReward, PromotionEntriesSet[])
Adds the promotion item record.
Declaration
public void AddPromotionItemRecord(PromotionReward reward, params PromotionEntriesSet[] entrySetsCollection)
Parameters
| Type | Name | Description |
|---|---|---|
| PromotionReward | reward | The reward. |
| PromotionEntriesSet[] | entrySetsCollection | The entry sets collection. |
CreatePromotionEntriesSetFromTarget(String)
Creates the promotion entries set from target.
Declaration
public PromotionEntriesSet CreatePromotionEntriesSetFromTarget(string entryCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | entryCode | The entry code. |
Returns
| Type | Description |
|---|---|
| PromotionEntriesSet |
CreatePromotionEntriesSetFromTarget(String, Decimal)
Creates the entry from target.
Declaration
public PromotionEntriesSet CreatePromotionEntriesSetFromTarget(string entryCode, decimal quantity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | entryCode | The entry code. |
| System.Decimal | quantity | The quantity. |
Returns
| Type | Description |
|---|---|
| PromotionEntriesSet |
CreatePromotionReward(String, Decimal, String)
Creates the promotion reward.
Declaration
public PromotionReward CreatePromotionReward(string rewardType, decimal amountOff, string amountType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | rewardType | Type of the reward. |
| System.Decimal | amountOff | The amount off. |
| System.String | amountType | Type of the amount. |
Returns
| Type | Description |
|---|---|
| PromotionReward |
CreatePromotionReward(String, String, String)
Creates the promotion reward. And validate input parameters
Declaration
public PromotionReward CreatePromotionReward(string rewardType, string amountOff, string amountType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | rewardType | Type of the reward. |
| System.String | amountOff | The amount off. |
| System.String | amountType | Type of the amount. |
Returns
| Type | Description |
|---|---|
| PromotionReward |
FindLineItemByCatalogNodeCode(String, OrderGroup)
Finds the line item by catalog node code.
Declaration
public LineItem FindLineItemByCatalogNodeCode(string nodeCode, OrderGroup orderGroup)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | nodeCode | The node code. |
| OrderGroup | orderGroup | The order group. |
Returns
| Type | Description |
|---|---|
| LineItem |
FindLineItemByEntryCode(String, OrderGroup)
Finds the line item by entry code.
Declaration
public LineItem FindLineItemByEntryCode(string entryCode, OrderGroup orderGroup)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | entryCode | The entry code. |
| OrderGroup | orderGroup | The order group. |
Returns
| Type | Description |
|---|---|
| LineItem |
GetCollectionSum(IEnumerable, String, CodeExpression)
Gets the collection sum.
Declaration
public decimal GetCollectionSum(IEnumerable collection, string fieldName, CodeExpression codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.String | fieldName | Name of the field. |
| System.CodeDom.CodeExpression | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Decimal |
GetCollectionSum(IEnumerable, String, String)
Gets the collection sum.
Declaration
public decimal GetCollectionSum(IEnumerable collection, string fieldName, string codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.String | fieldName | Name of the field. |
| System.String | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Decimal |
GetCollectionSum(Object, String, String)
Gets the collection sum.
Declaration
public decimal GetCollectionSum(object obj, string fieldName, string codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The obj. |
| System.String | fieldName | Name of the field. |
| System.String | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Decimal |
GetCount(IEnumerable)
Gets the count.
Declaration
public int GetCount(IEnumerable collection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
GetCount(Object)
Gets the count.
Declaration
public int GetCount(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The obj. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
GetValidatedCount(IEnumerable, CodeExpression)
Returns the number of items that satisfied the specified condition.
Declaration
public int GetValidatedCount(IEnumerable collection, CodeExpression codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.CodeDom.CodeExpression | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
GetValidatedCount(IEnumerable, String)
Returns the number of items that satisfied the specified condition.
Declaration
public int GetValidatedCount(IEnumerable collection, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
GetValidatedCount(Object, String)
Gets the validated count.
Declaration
public int GetValidatedCount(object obj, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The obj. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
ValidateAll(IEnumerable, CodeExpression)
Returns true if all of the items in the collection satisfies the specified condition.
Declaration
public bool ValidateAll(IEnumerable collection, CodeExpression codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.CodeDom.CodeExpression | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Returns false if collection does not contain any elements.
ValidateAll(IEnumerable, String)
Returns true if all of the items in the collection satisfies the specified condition.
Declaration
public bool ValidateAll(IEnumerable collection, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ValidateAll(Object, String)
Validates all.
Declaration
public bool ValidateAll(object obj, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The obj. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ValidateAny(IEnumerable, CodeExpression)
Returns true if any of the items in the collection satisfies the specified condition.
Declaration
public bool ValidateAny(IEnumerable collection, CodeExpression codeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.CodeDom.CodeExpression | codeExpr | The code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ValidateAny(IEnumerable, String)
Returns true if any of the items in the collection satisfies the specified condition.
Declaration
public bool ValidateAny(IEnumerable collection, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | collection | The collection. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ValidateAny(Object, String)
Validates any.
Declaration
public bool ValidateAny(object obj, string strCodeExpr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The obj. |
| System.String | strCodeExpr | The STR code expr. |
Returns
| Type | Description |
|---|---|
| System.Boolean |