// GET: Create
        public ActionResult Create(int id, bool isCard)
        {
            var userId      = User.Identity.GetUserId();
            var deckService = new DeckService(userId);
            var cardService = new CardService();

            if (isCard)
            {
                var allDecks   = deckService.GetDecks();
                var card       = cardService.GetCardById(id);
                var cardToDeck = new AssignmentViewModel(isCard)
                {
                    CardId   = id,
                    CardName = card.Name,
                    DeckList = allDecks
                };
                return(View(cardToDeck));
            }

            var allCards   = cardService.GetCards();
            var deck       = deckService.GetDeckById(id);
            var deckToCard = new AssignmentViewModel(isCard)
            {
                DeckId   = id,
                DeckName = deck.Name,
                CardList = allCards
            };

            return(View(deckToCard));
        }
Пример #2
0
        /// <summary>
        /// Get a single deck by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IHttpActionResult Get(int id)
        {
            DeckService deckService = CreateDeckService();
            var         deck        = deckService.GetDeckById(id);

            return(Ok(deck));
        }
Пример #3
0
        public async Task Given_A_DeckId_Should_Invoke_GetDeckById_Once()
        {
            // Arrange
            const int expected = 1;
            const int deckId   = 23423;

            _deckRepository.GetDeckById(Arg.Any <long>()).Returns(new DeckDetail {
                Id = 23423
            });

            // Act
            await _sut.GetDeckById(deckId);

            // Assert
            await _deckRepository.Received(expected).GetDeckById(deckId);
        }