Example #1
0
        public ActionResult EditDeck(int id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (TempData["addedCard_ID"] != null)
            {
                string     cardID    = TempData["addedCard_ID"].ToString();
                CardSqlDAL cDal      = new CardSqlDAL(connectionString);
                Card       addedCard = cDal.GetCardByID(cardID);
                ViewBag.AddedCard        = addedCard;
                TempData["addedCard_ID"] = null;
            }
            Deck deck = deckDAL.GetDeckByDeckID(id.ToString());

            if (deck.UserID != Session["userid"].ToString())
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                Session["deck_ID"] = deck.DeckID;
                return(View(deck));
            }
        }
Example #2
0
        //GET: Approve a Deck for public use
        public ActionResult ApproveDeck(string deck_id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("You are not authorized to perfom this function"));
            }
            string isAdmin = Session["admin"].ToString();

            Deck curDeck = dDal.GetDeckByDeckID(deck_id);

            curDeck.MakePublic(deck_id);

            return(View("Deck"));
        }
Example #3
0
        //begin study session
        public ActionResult BeginStudy(string deckID)
        {
            DeckSqlDAL dDal     = new DeckSqlDAL(connectionString);
            Deck       thisDeck = dDal.GetDeckByDeckID(deckID);

            return(View("StudySession", thisDeck));
        }
Example #4
0
        public void RemoveCardFromDeckTest()
        {
            //Arrange
            DeckSqlDAL deckSql  = new DeckSqlDAL(connectionString);
            Deck       testDeck = deckSql.GetDeckByDeckID(deckID.ToString());

            //Act
            testDeck.AddCardToDeck(cardID.ToString());
            bool deleted = deckSql.RemoveCardFromDeck(cardID.ToString(), deckID.ToString());

            //Assert
            Assert.IsTrue(deleted);
        }
Example #5
0
        public void ModifyDeckPublicTest()
        {
            //Arrange
            DeckSqlDAL deckSql = new DeckSqlDAL(connectionString);

            //Act
            bool success  = deckSql.ModifyDeckIsPublic(deckID.ToString(), true);
            Deck deckTest = deckSql.GetDeckByDeckID(deckID.ToString());

            //Assert
            Assert.IsTrue(success);
            Assert.AreEqual(true, deckTest.IsPublic);
        }
Example #6
0
        public void ThisDeckTagsTest()
        {
            //Arrange
            DeckSqlDAL deckSql  = new DeckSqlDAL(connectionString);
            TagsSqlDAL tagsDAL  = new TagsSqlDAL(connectionString);
            Deck       testDeck = deckSql.GetDeckByDeckID(deckID.ToString());

            //Act
            testDeck.AddTagToDeck("Deck Model Test");
            List <string> deckTags = testDeck.ThisDeckTags;

            //Assert
            Assert.AreEqual("Deck Model Test", deckTags[0]);
        }