Пример #1
0
        public Book Add(string title, string name)
        {
            var author = authorRepository.AuthorWithName(name);
            var book   = new Book(title, author);

            return(bookRepository.Add(book));
        }
Пример #2
0
        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);
            }
        }