Example #1
0
        public void DeleteBook(int id)
        {
            var db   = new bookEntities();
            var book = db.Books.Find(id);

            db.Books.Remove(book);
            db.SaveChanges();
        }
Example #2
0
        public void UpdateBook(int id, string namebook, string author, string
                               topic, string type)
        {
            var db   = new bookEntities();
            var book = db.Books.Find(id);

            book.NameBook     = namebook;
            book.Author       = author;
            book.TypeExchange = type;

            db.Entry(book).State = EntityState.Modified;
            db.SaveChanges();
        }
Example #3
0
        public void AddBook(string namebook, string author, string nameuser, string topic, string type)
        {
            var book = new Book();

            book.NameBook     = namebook;
            book.Author       = author;
            book.NameUser     = nameuser;
            book.Topic        = topic;
            book.TypeExchange = type;


            var db = new bookEntities();

            db.Books.Add(book);
            db.SaveChanges();
        }
Example #4
0
        public Book GetBook(int id)
        {
            var db = new bookEntities();

            return(db.Books.Find(id));
        }
Example #5
0
        public Book[] GetBooks()
        {
            var db = new bookEntities();

            return(db.Books.ToArray());
        }