コード例 #1
0
        public async Task <IActionResult> AddDeck([FromBody] DeckRequest deckRequest)
        {
            Deck _newDeck = await _flashcardDataRepository.AddDeck(deckRequest.Name);

            DeckResponseDto _deckResponseDto = _mapper.Map <DeckResponseDto>(_newDeck);

            return(CreatedAtAction(nameof(GetDeckById), new { id = _deckResponseDto.Id }, _deckResponseDto));
        }
コード例 #2
0
        public async Task <IActionResult> GetDeckById(int id)
        {
            Deck _deck = await _flashcardDataRepository.GetDeckById(id);

            if (_deck == null)
            {
                var resp = new ErrorResponse()
                {
                    Errors = new List <string>()
                    {
                        $"Deck with Id {id} not found"
                    }
                };
                return(NotFound(resp));
            }
            DeckResponseDto _deckResponseDto = _mapper.Map <DeckResponseDto>(_deck);

            return(Ok(_deckResponseDto));
        }