コード例 #1
0
 // 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));
     }
 }
コード例 #2
0
 // 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));
         }
     }
 }