public Book Add(string title, string name) { var author = authorRepository.AuthorWithName(name); var book = new Book(title, author); return(bookRepository.Add(book)); }
public Book EditBookWithTitle(string title, string newAuthor) { var book = bookRepository.WithTitle(title); if (book != null) { // Remove existing book bookRepository.Delete(book.Title); // Create new one with same title and different author var author = authorRepository.AuthorWithName(newAuthor); var newBook = new Book(title, author); bookRepository.Add(newBook); return(newBook); } else { return(null); } }