/// <summary> /// This override is the normally used one /// </summary> public void AddItemsById(int[] ids, bool useArmory, bool useWowhead, bool usePTR) { foreach (int id in ids) { Item newItem = null; // try the armory (if requested) if (useArmory) { newItem = Item.LoadFromId(id, true, true, false, false && usePTR); } // try wowhead PTR if ((newItem == null) && useWowhead && usePTR) { newItem = Item.LoadFromId(id, true, true, true, true); if (newItem != null) { ItemCache.AddItem(newItem, true); } } // try wowhead if (armory failed) or (force wowhead) or (force wowhead and ptr failed) if ((newItem == null) /*&& useWowhead*/) { newItem = Item.LoadFromId(id, true, true, true, false); if (newItem != null) { ItemCache.AddItem(newItem, true); } } // We still can't find the item if (newItem == null) { // TODO don't use message box if (MessageBox.Show("Unable to load item " + id.ToString() + ". Would you like to create the item blank and type in the values yourself?", "Item not found. Create Blank?", MessageBoxButton.OK) == MessageBoxResult.OK) { newItem = new Item("New Item " + id.ToString(), ItemQuality.Epic, ItemType.None, id, "temp", ItemSlot.Head, string.Empty, false, new Stats(), new Stats(), ItemSlot.None, ItemSlot.None, ItemSlot.None, 0, 0, ItemDamageType.Physical, 0f, string.Empty); ItemCache.AddItem(newItem); } } else { UpdateItemList(); // TODO this does not work, figure out how to select an item ItemGrid.SelectedItem = newItem; ItemCache.OnItemsChanged(); } } }
/// <summary> /// Attempts to apply an offer to the the checkout. /// </summary> /// <param name="offerCode"> /// The offer code. /// </param> /// <param name="autoAddOnSuccess"> /// A value indicating whether or not the reward should be added to the <see cref="ILineItemContainer"/> on success /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> /// <remarks> /// TODO move this to an InvoiceChainTask /// </remarks> public Attempt <IOfferResult <ILineItemContainer, ILineItem> > TryAwardOffer(string offerCode, bool autoAddOnSuccess = true) { // Check to make certain the customer did not already add this coupon before. The default behavior of the // line item collections will update the quantity by matching skus. if (ItemCache.Items.Contains(offerCode)) { return(Attempt <IOfferResult <ILineItemContainer, ILineItem> > .Fail(new OfferRedemptionException("This offer has already been added."))); } var foundOffer = _couponManager.Value.GetByOfferCode(offerCode, Customer); if (!foundOffer.Success) { return(Attempt <IOfferResult <ILineItemContainer, ILineItem> > .Fail(foundOffer.Exception)); } var coupon = foundOffer.Result; var attempt = coupon.TryApply(this.CloneItemCache(), Customer); if (!attempt.Success) { return(attempt); } if (!autoAddOnSuccess) { return(attempt); } // stuff the coupon configuration into extended data // this will be used to audit the redeemed offer in the Finalizing handler attempt.Result.Award.ExtendedData .SetValue( Core.Constants.ExtendedDataKeys.CouponReward, JsonConvert.SerializeObject(coupon.Settings.ToOfferSettingsDisplay())); // save the coupon into the original item cache ItemCache.AddItem(attempt.Result.Award.AsLineItemOf <ItemCacheLineItem>()); MerchelloContext.Services.ItemCacheService.Save(ItemCache); return(attempt); }
private void AddItemsById(int[] ids, bool useArmory, bool useWowhead) { foreach (int id in ids) { Item newItem = null; // try the armory (if requested) if (useArmory) { newItem = Item.LoadFromId(id, true, true, false); } // try wowhead (if requested) /*if ((newItem == null) && useWowhead) * { * newItem = Wowhead.GetItem(id.ToString(), true); * if (newItem != null) ItemCache.AddItem(newItem, true); * } * if ((newItem == null) && useWowhead) * { * newItem = Wowhead.GetItem("ptr", id.ToString(), true); * if (newItem != null) ItemCache.AddItem(newItem, true); * }*/ if (newItem == null) { // TODO don't use message box if (MessageBox.Show("Unable to load item " + id.ToString() + ". Would you like to create the item blank and type in the values yourself?", "Item not found. Create Blank?", MessageBoxButton.OK) == MessageBoxResult.OK) { newItem = new Item("New Item", ItemQuality.Epic, ItemType.None, id, "temp", ItemSlot.Head, string.Empty, false, new Stats(), new Stats(), ItemSlot.None, ItemSlot.None, ItemSlot.None, 0, 0, ItemDamageType.Physical, 0f, string.Empty); ItemCache.AddItem(newItem); } } else { UpdateItemList(); // TODO this does not work, figure out how to select an item ItemGrid.SelectedItem = newItem; } } }
public void Can_Verify_A_Vistor_Visits_Every_Line_item() { //// Arrange const int itemCount = 10; var itemCache = new ItemCache(Guid.NewGuid(), ItemCacheType.Basket) { Key = Guid.NewGuid() }; for (var i = 0; i < itemCount; i++) { itemCache.AddItem(MockLineItemDataMaker.MockItemCacheLineItemComplete(itemCache.Key)); } //// Act var vistor = new MockLineItemVistor(); itemCache.Items.Accept(vistor); //// Assert Assert.AreEqual(itemCount, vistor.Visited.Count()); }
public static void LoadItemSet1(Character character) { ItemCacheInstance itemCache = new ItemCacheInstance(); ItemCache.Instance = itemCache; itemCache.AddItem(new Item { Id = 63855, Stats = new Stats { Armor = 916, Stamina = 349, Intellect = 233, CritRating = 151, HasteRating = 158, } }); character.Head = new ItemInstance(63855, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 63797, Stats = new Stats { Stamina = 195, Intellect = 130, HitRating = 56, HasteRating = 36, MasteryRating = 78, } }); character.Neck = new ItemInstance(63797, 0, 0, 0, 0, 0, 82, 0); ItemCache.AddItem(new Item { Id = 63873, Stats = new Stats { Armor = 846, Stamina = 260, Intellect = 173, HitRating = 69, CritRating = 46, HasteRating = 115, } }); character.Shoulders = new ItemInstance(63873, 0, 0, 0, 0, 0, 81, 0); ItemCache.AddItem(new Item { Id = 56107, Stats = new Stats { Armor = 572, Stamina = 224, Intellect = 149, Spirit = 100, HasteRating = 100, } }); character.Back = new ItemInstance(56107, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 63786, Stats = new Stats { Armor = 1128, Stamina = 349, Intellect = 233, Spirit = 173, CritRating = 125, } }); character.Chest = new ItemInstance(63786, 0, 0, 0, 0, 0, 89, 0); ItemCache.AddItem(new Item { Id = 63826, Stats = new Stats { Armor = 493, Stamina = 195, Intellect = 130, HitRating = 76, HasteRating = 93, } }); character.Wrist = new ItemInstance(63826, 0, 0, 0, 0, 0, 81, 0); ItemCache.AddItem(new Item { Id = 63814, Stats = new Stats { Armor = 705, Stamina = 260, Intellect = 173, HitRating = 98, CritRating = 125, } }); character.Hands = new ItemInstance(63814, 0, 0, 0, 0, 0, 89, 0); ItemCache.AddItem(new Item { Id = 63921, Stats = new Stats { Armor = 664, Stamina = 298, Intellect = 199, CritRating = 101, MasteryRating = 151, } }); character.Waist = new ItemInstance(63921, 0, 0, 0, 0, 0, 111, 0); ItemCache.AddItem(new Item { Id = 56218, Stats = new Stats { Armor = 1002, Stamina = 401, Intellect = 268, Spirit = 178, MasteryRating = 157, } }); character.Legs = new ItemInstance(56218, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 66937, Stats = new Stats { Armor = 787, Stamina = 298, Intellect = 199, HitRating = 142, CritRating = 116 } }); character.Feet = new ItemInstance(66937, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 55276, Stats = new Stats { Stamina = 177, Intellect = 118, Spirit = 85, MasteryRating = 69, } }); character.Finger1 = new ItemInstance(55276, 0, 0, 0, 0, 0, 111, 0); ItemCache.AddItem(new Item { Id = 56000, Stats = new Stats { Stamina = 224, Intellect = 149, Spirit = 107, CritRating = 87 } }); character.Finger2 = new ItemInstance(56000, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 57346, Stats = new Stats { Intellect = 143, } }); character.Trinket1 = new ItemInstance(57346, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 61411, Stats = new Stats { Intellect = 194, } }); character.Trinket2 = new ItemInstance(61411, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 56097, Stats = new Stats { Stamina = 401, Intellect = 268, Spirit = 178, SpellPower = 1533, HasteRating = 178 } }); character.MainHand = new ItemInstance(56097, 0, 0, 0, 0, 0, 0, 0); ItemCache.AddItem(new Item { Id = 56122, Stats = new Stats { Stamina = 126, Intellect = 84, Spirit = 56, HasteRating = 56 } }); character.Ranged = new ItemInstance(56122, 0, 0, 0, 0, 0, 0, 0); }
public override bool AddObject(NebulaObject obj) { return(ItemCache.AddItem(obj as Item)); }