using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; namespace WebAPIRc.Models { public class BookRepository : IBookRepository { private BookStore db = new BookStore(); public BookRepository() { } public IEnumerable<Book> GetAll() { return db.Books; } public Book Get(int id) { return db.Books.Find(id); } public Book Add(Book item) { db.Books.Add(item); db.SaveChanges(); return item; } public void Remove(int id) { Book book = db.Books.Find(id); db.Books.Remove(book); db.SaveChanges(); } public bool Update(Book item) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return true; } } }
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Skills that self-taught computer programmers lack