public ActionResult IndexUpdate()
        {
            MagicCard userInput = new MagicCard(Request.Form["newCardName"], Request.Form["newCardColor"], Request.Form["newCardRarity"], Request.Form["newCardType"], Request.Form["newCardSet"]);

            userInput.Save();

            //Redirects to Index() after posting. This prevents the bug of adding the same items when refreshing after posting. Index doesn't refer to the index.cshtml but rather the function called Index() in this controller. You can add a second parameter after this to specify which controller if needed.
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public void Find_FindMagicCardDatabase_MagicCard()
        {
            //Arrange
            MagicCard testMagicCard = new MagicCard("1", "2", "2", "2", "2", 1);

            testMagicCard.Save();

            //Act
            MagicCard foundMagicCard = MagicCard.Find(testMagicCard.GetId());

            //Assert
            Assert.AreEqual(testMagicCard, foundMagicCard);
        }
Esempio n. 3
0
        public void Save_SavesCardToDatabase_MagicCardList()
        {
            MagicCard testCard = new MagicCard("1", "1", "1", "1", "1", 1);

            testCard.Save();

            List <MagicCard> result   = MagicCard.GetAll();
            List <MagicCard> testList = new List <MagicCard> {
                testCard
            };

            CollectionAssert.AreEqual(testList, result);
        }
Esempio n. 4
0
        public void Save_DatabaseAssignsIdToObject_Id()
        {
            //Arrange
            MagicCard testMagicCard  = new MagicCard("1", "1", "1", "1", "1", 1);
            MagicCard testMagicCard2 = new MagicCard("1", "1", "1", "1", "1", 1);

            //Act
            testMagicCard.Save();
            MagicCard savedCard = MagicCard.GetAll()[0];

            int result = savedCard.GetId();
            int testId = testMagicCard.GetId();

            //Assert
            Assert.AreEqual(testId, result);
        }