Class LoyaltyService
- Namespace
- Dynamicweb.Ecommerce.Loyalty
- Assembly
- Dynamicweb.Ecommerce.dll
public class LoyaltyService : ICacheStorage<int, Reward>, ICacheStorage<int>, ICacheStorage
- Inheritance
-
LoyaltyService
- Implements
- Inherited Members
Properties
AllowEarnPointsFromPurchasedPoints
Gets the value indicating wheither the buying items with points should earn more points.
public bool AllowEarnPointsFromPurchasedPoints { get; }
Property Value
Methods
ClearCache()
Resets all keys to the default value for objects stored in the object cache
public void ClearCache()
ClearCache(RewardKey)
[Obsolete("Use ClearCache(int) instead.")]
public void ClearCache(RewardKey key)
Parameters
keyRewardKey
ClearCache(IEnumerable<RewardKey>)
[Obsolete("Use ClearCache(IEnumerable<int>) instead.")]
public void ClearCache(IEnumerable<RewardKey> keys)
Parameters
keysIEnumerable<RewardKey>
ClearCache(IEnumerable<int>)
Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<int> keys)
Parameters
keysIEnumerable<int>- Keys to reset
ClearCache(int)
Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(int key)
Parameters
keyint- Key to reset
ClearRewardCache()
Remove all rewards from cache.
[Obsolete("Use ClearCache instead")]
public void ClearRewardCache()
ClearRewardRuleCache()
Remove all reward rules from cache.
public void ClearRewardRuleCache()
ClearUserTransactionCache()
Remove user transactions from cache.
[Obsolete("Use ClearUserTransactionCache(userId) instead.")]
public void ClearUserTransactionCache()
ClearUserTransactionCache(int)
Remove user transactions from cache.
public void ClearUserTransactionCache(int userId)
Parameters
userIdint
CreateTransaction(UserTransaction)
Creates the user transaction
public void CreateTransaction(UserTransaction transaction)
Parameters
transactionUserTransaction- The UserTransaction.
CreateTransaction(UserTransaction, OrderLine)
Creates the user transaction
public void CreateTransaction(UserTransaction transaction, OrderLine orderLine)
Parameters
transactionUserTransaction- The UserTransaction.
orderLineOrderLine- The OrderLine.
CreateTransaction(UserTransaction, User)
Creates the user transaction
public void CreateTransaction(UserTransaction transaction, User user)
Parameters
transactionUserTransaction- The UserTransaction.
userUser- The User.
DeleteReward(Reward)
Deletes the reward.
public void DeleteReward(Reward reward)
Parameters
rewardReward
DeleteRewardRule(RewardRule)
Deletes the instance.
public void DeleteRewardRule(RewardRule rewardRule)
Parameters
rewardRuleRewardRule
FindPoints(OrderLine)
Finds the points.
public IPointInfo FindPoints(OrderLine orderLine)
Parameters
orderLineOrderLine- The order line.
Returns
- IPointInfo
- The IPointInfo.
FindPoints(Product)
Finds the points.
[Obsolete("Use overload with order instead")]
public ConditionPointInfo FindPoints(Product product)
Parameters
productProduct- The product.
Returns
FindPoints(Product, Order, DateTime)
Finds the points.
public ConditionPointInfo FindPoints(Product product, Order order, DateTime orderTime)
Parameters
Returns
FindPoints(Product, Order, DateTime, string)
Finds the points.
public ConditionPointInfo FindPoints(Product product, Order order, DateTime orderTime, string unitId)
Parameters
productProduct- The product.
orderOrder- The order.
orderTimeDateTime- The order time.
unitIdstring- The unit ID.
Returns
FindPoints(Product, Order, string, DateTime)
Finds the points.
[Obsolete("Use overload without country code")]
public ConditionPointInfo FindPoints(Product product, Order order, string countryCode2, DateTime orderTime)
Parameters
productProduct- The product.
orderOrder- The order.
countryCode2string- The country code2.
orderTimeDateTime- The order time.
Returns
FindPoints(Product, Order, string, DateTime, string)
Finds the points.
[Obsolete("Use overload without country code")]
public ConditionPointInfo FindPoints(Product product, Order order, string countryCode2, DateTime orderTime, string unitId)
Parameters
productProduct- The product.
orderOrder- The order.
countryCode2string- The country code2.
orderTimeDateTime- The order time.
unitIdstring- The unit ID.
Returns
GetPointsBalance(User)
Gets the transaction balance for user.
public double GetPointsBalance(User user)
Parameters
Returns
GetPointsBalance(int)
Gets the transaction balance by user id.
public double GetPointsBalance(int userId)
Parameters
userIdint- The user id.
Returns
GetRewardById(int)
Gets reward by ID.
public Reward GetRewardById(int rewardId)
Parameters
rewardIdint- The reward id.
Returns
- Reward
- The reward.
GetRewardById(int, string)
Gets the reward by reward id and language Id.
[Obsolete("Use GetRewardById(int) instead.")]
public Reward GetRewardById(int rewardId, string languageId)
Parameters
Returns
- Reward
- The reward.
GetRewardRule(int, int)
Gets the reward rule.
public RewardRule GetRewardRule(int rewardId, int id)
Parameters
Returns
- RewardRule
- The RewardRule.
GetRewardRuleById(int)
Gets the reward rule by id.
[Obsolete("Use GetRewardRule instead")]
public RewardRule GetRewardRuleById(int id)
Parameters
idint- The reward id.
Returns
- RewardRule
- The RewardRule.
GetRewards()
Return all rewards.
public IEnumerable<Reward> GetRewards()
Returns
GetRewards(bool)
Return all rewards.
[Obsolete("Use GetRewards() instead. Call ClearCache() first, if needed.")]
public IEnumerable<Reward> GetRewards(bool force)
Parameters
forcebool- Force cahce update.
Returns
GetRewards(bool, string)
Return all rewards.
[Obsolete("Use GetRewards() instead. Call ClearCache() first, if needed. Use Reward.Translations to access the translations for each reward.")]
public IEnumerable<Reward> GetRewards(bool force, string languageId)
Parameters
Returns
GetRewards(bool, string, bool?, RewardCollectionSortDirection, RewardCollectionSortBy)
Return all rewards.
[Obsolete("Use GetRewards() instead. Call ClearCache() first, if needed. Use Reward.Translations to access the translations for each reward. Filter and sort the collection, if needed.")]
public IEnumerable<Reward> GetRewards(bool force, string languageId, bool? archiveMode, RewardCollectionSortDirection sortDirection, RewardCollectionSortBy sortBy)
Parameters
forcebool- Force cahce update.
languageIdstring- The language id.
archiveModebool?- The archive mode. Nothing - all, true - archived only, false - unarchived only.
sortDirectionRewardCollectionSortDirectionsortByRewardCollectionSortBy
Returns
GetRewardsGiven(IEnumerable<Reward>)
Gets the points given for the specified list of rewards.
public IEnumerable<RewardPointsGiven> GetRewardsGiven(IEnumerable<Reward> rewards)
Parameters
rewardsIEnumerable<Reward>- The rewards.
Returns
- IEnumerable<RewardPointsGiven>
- IEnumerable(Of RewardPointsGiven).
GetRewardUsageCount(Reward)
Gets the count of the reward usage.
public int GetRewardUsageCount(Reward reward)
Parameters
rewardReward
Returns
- int
- Number of the reward usage.
GetRulesForReward(int)
Gets rules for the reward id.
public IEnumerable<RewardRule> GetRulesForReward(int rewardId)
Parameters
rewardIdint- The reward id.
Returns
GetTotalPoints(Reward, double, double, double)
Gets the total points.
public double GetTotalPoints(Reward reward, double productsPrice, double productsCount, double divisor)
Parameters
rewardRewardproductsPricedouble- The products price.
productsCountdouble- The products count.
divisordouble- The divisor.
Returns
- double
- The total points.
GetUserTransactions()
Gets the collection of all user transactions.
[Obsolete("Use GetUserTransactions(userId) instead")]
public IEnumerable<UserTransaction> GetUserTransactions()
Returns
GetUserTransactions(int)
Gets the collection of the user transactions by user id.
public IEnumerable<UserTransaction> GetUserTransactions(int userId)
Parameters
userIdint- The user id.
Returns
LoadRewardsFromUserTransaction(IEnumerable<UserTransaction>)
Loads the rewards from the user transaction collection.
public void LoadRewardsFromUserTransaction(IEnumerable<UserTransaction> userTransactions)
Parameters
userTransactionsIEnumerable<UserTransaction>- The collection of user transactions.
LoadRulesForRewards(IEnumerable<Reward>)
Loads rules for specified rewards.
[Obsolete("Don't use this.")]
public void LoadRulesForRewards(IEnumerable<Reward> rewards)
Parameters
rewardsIEnumerable<Reward>- The RewardCollection.
RedeemExpiredPoints()
public void RedeemExpiredPoints()
RedeemPoints(Order)
Redeem points from Order.
public void RedeemPoints(Order order)
Parameters
RedeemPoints(double, string, int)
Redeem points.
public void RedeemPoints(double points, string comment, int userId)
Parameters
pointsdouble- The number of points.
commentstring- The comment for transaction.
userIdint- The user id.
RedeemPoints(double, string, int, DateTime)
Redeem points.
public void RedeemPoints(double points, string comment, int userId, DateTime transactionDate)
Parameters
pointsdouble- The number of points.
commentstring- The comment for transaction.
userIdint- The user id.
transactionDateDateTime- The transaction date.
RedeemPoints(double, string, int, DateTime, TransactionObjectType, string)
public void RedeemPoints(double points, string comment, int userId, DateTime transactionDate, TransactionObjectType transactionType, string transactionElement)
Parameters
pointsdoublecommentstringuserIdinttransactionDateDateTimetransactionTypeTransactionObjectTypetransactionElementstring
RewardPoints(Order)
Reward points from order lines on an order.
public void RewardPoints(Order order)
Parameters
orderOrder- The order.
RewardPoints(double, string, int)
Reward points.
public void RewardPoints(double points, string comment, int userId)
Parameters
pointsdouble- The number of points.
commentstring- The comment for transaction.
userIdint- The user id.
SaveReward(Reward)
Saves current reward to the database.
public void SaveReward(Reward reward)
Parameters
rewardReward
SaveRewardRule(RewardRule)
Saves the instance to the data base.
public void SaveRewardRule(RewardRule rewardRule)
Parameters
rewardRuleRewardRule
SetNewRewardCurrency(Reward, Currency)
Sets new currency code and recalculates points count.
[Obsolete("Don't use this.")]
public void SetNewRewardCurrency(Reward reward, Currency currency)
Parameters
TryUpdateRewards(Order)
Tries to update rewards.
public void TryUpdateRewards(Order order)
Parameters
orderOrder- The order.
UsePoints(Order)
Redeem points from Order and exchange points in case of Loyalty discount is used.
public void UsePoints(Order order)