private void deleteButton_Click(object sender, EventArgs e)
        {
            var itemToDelete = (Item)ItemListBox.SelectedItem;

            if (itemToDelete == null)
            {
                return;
            }

            using (var context = new ItsOnlyHeroesEntities())
            {
                var item = context.Items.Find(itemToDelete.ItemId);
                if (item != null)
                {
                    item.Active = false;
                    context.SaveChanges();
                }
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            var itemToSave = (Item)ItemListBox.SelectedItem;

            if (itemToSave == null)
            {
                return;
            }

            using (var context = new ItsOnlyHeroesEntities())
            {
                Item item = new Item();

                if (itemToSave.ItemId > 0)
                {
                    item = context.Items.Find(itemToSave.ItemId);
                }
                else
                {
                    context.Items.Add(item);
                }

                //there's probably a better way to copy this over, but you only have context from EF items.
                var updatedItem = GetItemFromView();
                item.Name          = updatedItem.Name;
                item.Stat          = updatedItem.Stat;
                item.SellValue     = updatedItem.SellValue;
                item.BuyValue      = updatedItem.BuyValue;
                item.BuyCurrencyId = updatedItem.BuyCurrencyId;
                item.ItemTypeId    = updatedItem.ItemTypeId;
                item.Active        = updatedItem.Active;
                item.Description   = updatedItem.Description;

                context.SaveChanges();
            }

            //probably not the best way to do this.
            GetItems();
            ItemListBox.SelectedItem = ItemListBox.Items.OfType <Item>()
                                       .Where(i => i.ItemId == itemToSave.ItemId)
                                       .FirstOrDefault();
        }
        private void addCurrencyTypeButton_Click(object sender, EventArgs e)
        {
            var  newType = ItemTypeComboBox.Text;
            bool exists  = ItemTypeComboBox.Items.OfType <ItemType>()
                           .Where(i => i.ItemTypeName == newType).Any();

            if (exists) //if it exists, we should update it.
            {
                return;
            }

            var newItemType = new ItemType();

            newItemType.ItemTypeName        = newType;
            newItemType.ItemTypeDescription = typeDescriptionTextBox.Text;

            using (var context = new ItsOnlyHeroesEntities())
            {
                context.ItemTypes.Add(newItemType);
                context.SaveChanges();
            }
            GetItemTypes();
        }