/// <summary> /// Adds a new basket item to this WishlistItem collection /// </summary> /// <param name="item">Basket item based on which to create a new WishlistItem</param> public void Add(BasketItem item) { WishlistItem wishlistItem = new WishlistItem(); wishlistItem.ProductId = item.ProductId; wishlistItem.OptionList = item.OptionList; wishlistItem.KitList = item.KitList; wishlistItem.Desired = item.Quantity; //DEFAULT MEDIUM PRIORITY wishlistItem.Priority = 2; if (item.Product.UseVariablePrice) { wishlistItem.Price = item.Price; } wishlistItem.LineMessage = item.LineMessage; //COPY OVER ITEM INPUTS foreach (BasketItemInput input in item.Inputs) { WishlistItemInput cloneInput = new WishlistItemInput(); cloneInput.InputFieldId = input.InputFieldId; cloneInput.InputValue = input.InputValue; wishlistItem.Inputs.Add(cloneInput); } this.Add(wishlistItem); }
/// <summary> /// Can this WishlistItem combine with the given WishlistItem? /// </summary> /// <param name="other"></param> /// <returns>True if this item can combine with the given WishlistItem, false otherwise</returns> public bool CanCombine(WishlistItem other) { if (other == null) { throw new ArgumentNullException("other"); } if (this.ProductId != other.ProductId) { return(false); } if (this.OptionList != other.OptionList) { return(false); } if (this.KitList != other.KitList) { return(false); } if (this.LineMessage != other.LineMessage) { return(false); } if (this.Inputs.Count > 0) { //compare all of the input values to see if they match if (this.Inputs.Count != other.Inputs.Count) { return(false); } foreach (WishlistItemInput input in this.Inputs) { WishlistItemInput otherInput = WishlistItem.GetInput(other.Inputs, input.InputFieldId); if (otherInput == null) { return(false); } if (!input.InputValue.Equals(otherInput.InputValue)) { return(false); } } } if ((this.Product.UseVariablePrice) && (this.Price != other.Price)) { return(false); } return(true); }