public async Task <IActionResult> PutTrivia(int id, TriviaDto triviaDto) { if (id != triviaDto.Id) { return(BadRequest()); } try { var trivia = _mapper.Map <Trivia>(triviaDto); await _repository.Update(trivia); } catch (DbUpdateConcurrencyException) { if (!TriviaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TriviaDto> > PostTrivia(TriviaDto triviaDto) { var trivia = _mapper.Map <Trivia>(triviaDto); trivia = await _repository.Add(trivia); var result = _mapper.Map <TriviaDto>(trivia); return(CreatedAtAction("GetTrivia", new { id = result.Id }, result)); }
public async Task <ActionResult <MovieDto> > CreateTrivia(int movieId, TriviaDto trivia) { var result = await handler.AddTrivia(movieId, trivia); return(Ok(result)); }