// GET: api/Autor/5 public Author Get(int id) { using (IConnection connection = new ConnectionFactory()) { connection.Open(); IDao <Author> author = new AuthorDao(connection); return(author.FindId(id)); } }
// PUT: api/Autor/5 public void Put(long id, [FromBody] Author model) { using (IConnection connection = new ConnectionFactory()) { connection.Open(); IDao <Author> dao = new AuthorDao(connection); if (string.IsNullOrEmpty(model.Name) || string.IsNullOrEmpty(model.LastName)) { new Exception("Valor não pode ser vazio!"); } Author author = dao.FindId(id); if (author != null) { dao.Update(new Author(author.Id, model.Name, model.LastName)); } } }