Esempio n. 1
0
        // Add new book
        // POST: /api/book
        public IHttpActionResult PostBook(Book book)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            repo.AddBook(book);

            return Ok();
        }
Esempio n. 2
0
        // Update book
        // PUT: /api/book/id
        public IHttpActionResult PutBook(int id, Book book)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != book.BookId)
            {
                return BadRequest();
            }

            repo.EditBook(book);

            return Ok();
        }
Esempio n. 3
0
 public void UpdateBook(Book book)
 {
     _db.Entry(book).State = EntityState.Modified;
 }
Esempio n. 4
0
 public void CreateBook(Book book)
 {
     _db.Books.Add(book);
 }
Esempio n. 5
0
 public void AddBook(Book book)
 {
     db.Books.Add(book);
     SaveChanges();
 }
Esempio n. 6
0
 public void EditBook(Book book)
 {
     db.Entry(book).State = EntityState.Modified;
     SaveChanges();
 }