public async Task <IActionResult> PostAuthor([FromBody] Author author) { if (!ModelState.IsValid) { return(BadRequest("Error verifique os campos e tente novamente mais tarde.")); } var authorDb = await _authorsRepository.GetAuthorByNameAsync(author.Name); if (authorDb != null) { return(BadRequest("Já existe um autor com esse nome.")); } await _authorsRepository.IncludeAsync(author); var uri = Url.Action("GetAuthor", new { id = author.Id }); return(Created(uri, author)); }