コード例 #1
0
        public async Task <IActionResult> GetCardsByDeckId(int id)
        {
            var deck = await _flashcardClient.GetDeckById(id);

            if (deck == null)
            {
                return(Json(new EmptyResult()));
            }
            var result = await _flashcardClient.GetCardsByDeckId(id);

            return(Json(result.Cards));
        }
コード例 #2
0
        public async Task <ViewResult> Index(int id)
        {
            var deck = await _flashcardClient.GetDeckById(id);

            var cardsByDeckId = await _flashcardClient.GetCardsByDeckId(id);

            if (deck != null && cardsByDeckId != null)
            {
                var deckViewModel = new DeckViewModel()
                {
                    Id         = deck.Id,
                    Name       = deck.Name,
                    TotalCards = deck.totalCards,
                    Cards      = cardsByDeckId.Cards
                };

                return(View(deckViewModel));
            }
            else
            {
                return(View("NotFound"));
            }
        }