public void CanDeleteItem()
        {
            Item itemToAdd = new Item();
            var  repo      = new PirateItemRepository();

            itemToAdd.ItemName       = "Test Item";
            itemToAdd.RealValue      = 15000;
            itemToAdd.DisplayValue   = 20000;
            itemToAdd.Description    = "This is a test item";
            itemToAdd.Favorite       = true;
            itemToAdd.Featured       = true;
            itemToAdd.CategoryName   = "Space Goats";
            itemToAdd.CurrencyName   = "Space Bucks";
            itemToAdd.ItemPictureURL = "placeholder.jpg";

            repo.Insert(itemToAdd);
            Assert.AreEqual(9, itemToAdd.ItemId);

            var loaded = repo.GetItemById(9);

            Assert.IsNotNull(loaded);
            Assert.AreEqual(9, loaded.ItemId);

            repo.Delete(9);
            loaded = repo.GetItemById(9);

            Assert.IsNull(loaded);
        }
Esempio n. 2
0
        public ActionResult EditItem(int id)
        {
            var model = new ItemEditViewModel();

            var currenciesRepo = new CurrencyRepository();
            var categoriesRepo = new CategoryRepository();
            var ItemRepo       = new PirateItemRepository();

            model.Currencies = new SelectList(currenciesRepo.GetAll(), "CurrencyId", "CurrencyName");
            model.Categories = new SelectList(categoriesRepo.GetAll(), "CategoryId", "CategoryName");
            model.Item       = ItemRepo.GetItemById(id);

            return(View(model));
        }