public void AddItem(MapleCashShopInventoryItem citem) { if (CashShopItems.ContainsKey(citem.UniqueId)) { CashShopItems[citem.UniqueId] = citem; } else { CashShopItems.Add(citem.UniqueId, citem); } }
public void Load(int id) { try { using (var db = new NeoMapleStoryDatabase()) { var cashItemQuery = db.CashShopInventories.Where(x => x.AId == m_accountId).Select(x => x); foreach (var item in cashItemQuery) { var citem = new MapleCashShopInventoryItem(item.UniqueId, item.ItemId, item.Sn, item.Quantity, item.IsGift) { Expire = item.ExpireDate, Sender = item.Sender }; if (CashShopItems.ContainsKey(citem.UniqueId)) { CashShopItems[citem.UniqueId] = citem; } else { CashShopItems.Add(citem.UniqueId, citem); } } var cashGiftQuery = db.CashShopGifts.Where(x => x.AId == m_accountId).Select(x => x); foreach (var giftinfo in cashGiftQuery) { MapleCashShopInventoryItem gift; if (giftinfo.ItemId >= 5000000 && giftinfo.ItemId <= 5000100) { int petId = MaplePet.Create(giftinfo.ItemId, m_player); gift = new MapleCashShopInventoryItem(petId, giftinfo.ItemId, giftinfo.Sn, 1, true); } else { gift = new MapleCashShopInventoryItem(giftinfo.RingUniqueId, giftinfo.ItemId, giftinfo.Sn, giftinfo.Quantity, true) { IsRing = giftinfo.RingUniqueId > 0 }; } gift.Expire = giftinfo.ExpireDate; gift.Sender = giftinfo.Sender; gift.Message = giftinfo.Message; if (CashShopGifts.ContainsKey(gift.UniqueId)) { CashShopGifts[gift.UniqueId] = gift; } else { CashShopGifts.Add(gift.UniqueId, gift); } if (CashShopItems.ContainsKey(gift.UniqueId)) { CashShopItems[gift.UniqueId] = gift; } else { CashShopItems.Add(gift.UniqueId, gift); } Save(); } var deleteGiftQuery = db.CashShopGifts.Where(x => x.AId == m_accountId).Select(x => x); db.CashShopGifts.RemoveRange(deleteGiftQuery); db.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e.Message); } }