Exemplo n.º 1
0
        public async Task <IList <GetDeckResponse> > GetDecks()
        {
            var decks = await _context.Decks
                        .Include(d => d.CardDecks)
                        .ThenInclude(cd => cd.Card)
                        .ToListAsync();

            var decksResponse = GetDeckResponse.FromDeckEntity(decks);

            return(decksResponse);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <GetDeckResponse> > GetDeck(int id)
        {
            var deck = await _context.Decks
                       .Include(d => d.CardDecks)
                       .ThenInclude(cd => cd.Card)
                       .FirstOrDefaultAsync(d => d.DeckId == id);

            if (deck == null)
            {
                return(NotFound());
            }

            var deckResponse = GetDeckResponse.FromDeckEntity(deck);

            return(deckResponse);
        }