예제 #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"));
            }
        }
예제 #3
0
        public async Task <IActionResult> DeleteDeck(int deckId)
        {
            var deck = await _flashcardClient.GetDeckById(deckId);

            if (deck != null)
            {
                var result = await _flashcardClient.DeleteDeckById(deckId);

                if (!result.IsSuccess)
                {
                    return(NotFound());
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("NotFound"));
            }
        }