protected AmountBasedReward(AmountBasedReward other) : base(other) { AmountType = other.AmountType; Amount = other.Amount; Quantity = other.Quantity; }
protected AmountBasedReward (AmountBasedReward other) :base(other) { AmountType = other.AmountType; Amount = other.Amount; Quantity = other.Quantity; }
protected AmountBasedReward(AmountBasedReward other) : base(other) { AmountType = other.AmountType; Amount = other.Amount; Quantity = other.Quantity; MaxLimit = other.MaxLimit; ForNthQuantity = other.ForNthQuantity; InEveryNthQuantity = other.InEveryNthQuantity; }
private static AmountBasedReward EvaluateBestAmountReward(decimal currentAmount, AmountBasedReward[] promoRewards) { AmountBasedReward retVal = null; var maxAbsoluteReward = promoRewards .Where(y => y.AmountType == RewardAmountType.Absolute) .OrderByDescending(y => y.Amount).FirstOrDefault(); var maxRelativeReward = promoRewards .Where(y => y.AmountType == RewardAmountType.Relative) .OrderByDescending(y => y.Amount).FirstOrDefault(); var absDiscountAmount = maxAbsoluteReward != null ? maxAbsoluteReward.Amount : 0; var relDiscountAmount = maxRelativeReward != null ? currentAmount * maxRelativeReward.Amount : 0; if (maxAbsoluteReward != null && maxRelativeReward != null) { if (absDiscountAmount > relDiscountAmount) { retVal = maxAbsoluteReward; } else { retVal = maxRelativeReward; } } else if (maxAbsoluteReward != null) { retVal = maxAbsoluteReward; } else if (maxRelativeReward != null) { retVal = maxRelativeReward; } return retVal; }
private static AmountBasedReward[] EvaluteBestAmountRewards(decimal currentAmount, AmountBasedReward[] promoRewards) { var retVal = new List<AmountBasedReward>(); var bestReward = EvaluateBestAmountReward(currentAmount, promoRewards.Where(x => x.IsValid).ToArray()); if (bestReward != null) { retVal.Add(bestReward); } var bestPotentialReward = EvaluateBestAmountReward(currentAmount, promoRewards.Where(x => !x.IsValid).ToArray()); if (bestPotentialReward != null && bestReward != null) { var bestRewardFromTwo = bestReward = EvaluateBestAmountReward(currentAmount, new AmountBasedReward[] { bestReward, bestPotentialReward }); if (bestRewardFromTwo == bestPotentialReward) { retVal.Add(bestPotentialReward); } } else if (bestPotentialReward != null) { retVal.Add(bestPotentialReward); } return retVal.ToArray(); }