Exemplo n.º 1
0
        [TestMethod] //GetDeckById
        public void GetDeckByIdReturnsCorrectDeck()
        {
            //Act
            Deck result = dal.GetDeckById(testDeckId);

            //Assert
            Assert.AreEqual(result.Name, testDeck.Name);
            Assert.AreEqual(result.Description, testDeck.Description);
        }
Exemplo n.º 2
0
        public IActionResult ViewDeck(int deckId)
        {
            int? userId = authProvider.GetCurrentUser().Id;
            Deck deck   = decksSqlDAL.GetDeckById(deckId);

            if (authProvider.IsAdmin())
            {
                return(View("ViewDeckAdmin", deck));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 3
0
        public IActionResult ViewDeck(int deckId)
        {
            Deck deck = decksSqlDAL.GetDeckById(deckId);

            if (authProvider.GetCurrentUser() == null)
            {
                if (IsDeckPublic(deckId))
                {
                    return(View("AnonViewDeck", deck));
                }
                else
                {
                    return(NotFound());
                }
            }
            int userId = authProvider.GetCurrentUser().Id;

            if (IsCurrentUserTheOwner(deckId))
            {
                return(View(deck));
            }
            else if (IsDeckPublic(deckId))
            {
                OtherUsersDeckViewModel oudvm = new OtherUsersDeckViewModel()
                {
                    Deck = deck
                };
                oudvm.DeckOwnerName       = decksSqlDAL.GetUserNameFromDeckId(deck.Id);
                oudvm.UserDecksSelectList = decksSqlDAL.GetUserDecksSelectList(userId);
                return(View("NotOwnersDeck", oudvm));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 4
0
        // GET: API/GetDeck?Id=
        public Deck GetDeck(int Id)
        {
            Deck deck = decksSqlDAL.GetDeckById(Id);

            return(deck);
        }