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