private ShoppingCartItem(IShoppingCartItem item) { ID = (item.ID != Guid.Empty) ? item.ID : Guid.NewGuid(); ItemCode = GlobalUtilities.Coalesce(item.ItemCode); ParentItemCode = GlobalUtilities.Coalesce(item.ParentItemCode); Description = item.ItemDescription; ItemDescription = item.ItemDescription; Quantity = item.Quantity; DynamicKitCategory = GlobalUtilities.Coalesce(item.DynamicKitCategory); GroupMasterItemCode = GlobalUtilities.Coalesce(item.GroupMasterItemCode); Type = item.Type; Category = item.Category; PriceTypeID = item.PriceTypeID; Price = item.Price; PriceEachOverride = item.PriceEachOverride; BusinessVolumeEachOverride = item.BusinessVolumeEachOverride; CommissionableVolumeEachOverride = item.CommissionableVolumeEachOverride; ApplyDiscountType = item.ApplyDiscountType; AppliedAmount = item.AppliedAmount; InventoryStatus = item.InventoryStatus; OtherCheck1 = item.OtherCheck1; OtherCheck2 = item.OtherCheck2; OtherCheck3 = item.OtherCheck3; OtherCheck4 = item.OtherCheck4; OtherCheck5 = item.OtherCheck5; Field1 = item.Field1; Field2 = item.Field2; if (item.ApplyDiscountType == DiscountType.Unknown) { Discounts = new List <Discount>(); } else { var factory = new DiscountFactory(); Discounts = new List <Discount> { factory.CreateDiscount(ApplyDiscountType, item.AppliedAmount) }; } }
/// <summary> /// Creates and adds eligible discounts per product. /// </summary> /// <param name="products"></param> /// <param name="includeDiscounts"></param> /// <param name="includeBookingRewardDiscount"></param> /// <param name="event"></param> protected virtual void PopulateEligibleDiscounts( List <Product> products, bool includeDiscounts = false, bool includeBookingRewardDiscount = false, Event @event = null) { foreach (var product in products) { // TODO: Inject DiscountFactory dependency DiscountFactory factory = new DiscountFactory(); if (includeDiscounts) { if (!string.IsNullOrWhiteSpace(product.Field4) && product.Field4 != "No") { product.EligibleDiscounts.Add(factory.CreateDiscount(DiscountType.RewardsCash, 0M)); } if (!string.IsNullOrWhiteSpace(product.Field5) && product.Field5 != "No" && null != @event) { product.EligibleDiscounts.Add(factory.CreateDiscount(DiscountType.HalfOffCredits, 0.5M)); } if (!string.IsNullOrWhiteSpace(product.Field5) && product.Field5 != "No" && null == @event) { product.EligibleDiscounts.Add(factory.CreateDiscount(DiscountType.SAHalfOff, 0.5M)); } if (!string.IsNullOrWhiteSpace(product.Field6) && product.Field6 != "No") { product.EligibleDiscounts.Add(factory.CreateDiscount(DiscountType.NewProductsLaunchReward, 0.5M)); } //if (null != @event) //{ // var hostSpecialReward = factory.CreateDiscount(DiscountType.HostSpecial, @event, 0M); // // TODO: Add eligibility for Host Special Reward // product.EligibleDiscounts.Add(hostSpecialReward); //} } else { if (product.PriceTypeID != PriceTypes.Wholesale) { // new 10% PRV Currently no Start Date and End Date is given // Exclude manually on Replicated Site Controller product.EligibleDiscounts.Add(factory.CreateDiscount(DiscountType.ProductCredit, 0M)); } } //if (includeBookingRewardDiscount) //{ // product.EligibleDiscounts.Add(new DiscountFactory().CreateDiscount(DiscountType.BookingRewards, 0M)); //} //if (Convert.ToBoolean(HttpContext.Current.Cache["RecruitingRewardEligibility"]) && (product.CategoryId != 0 && product.CategoryId != 34 && product.CategoryId != 40 && product.CategoryId != 43 && product.CategoryId != 44 && product.CategoryId != 45 && product.CategoryId != 46 && product.CategoryId != 51)) //We should not add these as rewards to the SA Half off products. //{ // product.EligibleDiscounts.Add(new DiscountFactory().CreateDiscount(DiscountType.RecruitingReward, 0M)); //} //if (Convert.ToBoolean(HttpContext.Current.Cache["EnrolleeRewardEligibility"]) && (product.CategoryId != 0 && product.CategoryId != 34 && product.CategoryId != 40 && product.CategoryId != 43 && product.CategoryId != 44 && product.CategoryId != 45 && product.CategoryId != 46 && product.CategoryId != 51)) //We should not add these as rewards to the SA Half off products. //{ // product.EligibleDiscounts.Add(new DiscountFactory().CreateDiscount(DiscountType.EnrolleeReward, 0M)); //} } }