Exemplo n.º 1
0
        public void UpdateBook(Book book)
        {
            var genreRepository = new GenresRepository();

            book.Genre = genreRepository.Get(book.GenreId);
            var existingBook = _allBooks.FirstOrDefault(x => x.Id == book.Id);

            _allBooks.Remove(existingBook);
            _allBooks.Add(book);
        }
Exemplo n.º 2
0
        public int AddBook(Book book)
        {
            var maxId = _allBooks.Select(x => x.Id).Max();

            book.Id = maxId + 1;

            var genreRepository = new GenresRepository();

            book.Genre = genreRepository.Get(book.GenreId);

            _allBooks.Add(book);

            return(book.Id.Value);
        }