/// <summary> /// This method returns the list of item codes which the customer has already purchased. /// </summary> protected IList <string> RedeemedandExpiredItemCodes() { List <string> itemCodes = new List <string>(); var rewards = RewardService.GetCustomerEbRewardDiscounts(CustomerId); foreach (var reward in rewards) { string sku = reward.ItemCode; // There shouldn't be any duplicates but it is better to perform the check just in case versus having the application crash... // AzamNote: This is where we let the reward be redeemable for 30 days after completion!!! if (!itemCodes.Contains(sku) && (reward.HasBeenRedeemed || DateTime.Now >= reward.CompletionDate)) { itemCodes.Add(sku); } } return(itemCodes); }
/// <summary> /// This method returns all active reward products for this reward. /// </summary> public IList <Product> GetActiveRewardProducts(IList <Product> productsInShoppingCart) { if (!isEligible) { throw new Exception("IsEligible must be called first to ensure the customer is eligible for any discounts."); } IList <string> ebRewardProductsInCart = productsInShoppingCart.Where(p => p.Discounts.Any(d => d.DiscountType == DiscountType.EBRewards)).Select(p => p.ItemCode).ToList(); var activeRewardProducts = new List <Product>(); var rewards = RewardService.GetCustomerEbRewardDiscounts(CustomerId) // AzamNote: This is where we let the reward be redeemable for 30 days after completion!!! .Where(ebr => !ebr.HasBeenRedeemed && ebr.CompletionDate >= DateTime.Now); foreach (var reward in rewards) { var product = ProductService.GetProductByItemCode(reward.ItemCode, returnLongDetail: false); if (ebRewardProductsInCart.Contains(product.ItemCode)) { continue; } var discount = new EBRewardDiscount() { CustomerExtendedDetailId = reward.CustomerExtendedDetailId, ItemCode = reward.ItemCode, DiscountAmount = reward.DiscountPercent, DiscountPercent = reward.DiscountPercent, DiscountType = DiscountType.EBRewards, PhaseNumber = reward.PhaseNumber, HasBeenRedeemed = reward.HasBeenRedeemed, CompletionDate = reward.CompletionDate, }; product.EligibleDiscounts.Add(discount); activeRewardProducts.Add(product); } return(activeRewardProducts); }