Esempio n. 1
0
        public void Save(Book book)
        {
            //book.Id = new BooksDB().Books.Count() + 1;

            _booksDB.Books.Add(book);
            _booksDB.SaveChanges();
        }
Esempio n. 2
0
        public void Update(Book book)
        {
            var existingBook = _booksDB.Books.FirstOrDefault(b => b.Id == book.Id);
            _booksDB.Books.Remove(existingBook);

            //TODO: change below code to use AutoMapper
            existingBook.Title = book.Title;
            existingBook.Author = book.Author;
            existingBook.Keywords = book.Keywords;
            existingBook.CoverImage = book.CoverImage;
            existingBook.ReleaseDate = book.ReleaseDate;
            _booksDB.Books.Add(existingBook);
        }