public int EditBook(int id, Book book) { var bookIndex = _allBooks.FindIndex(x => x.Id == id); var genreRepository = new GenreRepository(); book.Genre = genreRepository.Get(book.GenreId); _allBooks[bookIndex] = book; return(book.Id); }
public int AddBook(Book book) { var maxId = _allBooks.Select(x => x.Id).Max(); book.Id = maxId + 1; var genreRepository = new GenreRepository(); book.Genre = genreRepository.Get(book.GenreId); _allBooks.Add(book); return(book.Id); }