// GET api/<controller>/5 public HttpResponseMessage Get(int id) { var editora = EditoraRepositorio.ObterPeloId(id); if (editora == null) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, EditoraRepositorio.GerarDto(EditoraRepositorio.ObterPeloId(id)))); }
// PUT api/<controller>/5 public void Put(int id, [FromBody] EditoraDto editora) { var editoraExistente = EditoraRepositorio.ObterPeloId(id); if (editoraExistente == null) { editora.Id = id; EditoraRepositorio.InserirNovoItem(editora); } else { editoraExistente.Nome = editora.Nome; } }