private static BookInformation Convert(Book book) { BookInformation bookInformation = null; if (book != null) { bookInformation = new BookInformation() { BookSeries = book.book_series, Annotation = book.annotation, FullTitle = book.full_title, ISBN = book.id_book_isbn, Language = book.language, PublishDate = book.date_publish, PublishHouse = new PublishHouseInformation() { Category = book.PublishingHouse.category, Location = book.PublishingHouse.location, Name = book.PublishingHouse.name }, Subject = new SubjectInformation() { Name = book.Subject.name, }, Title = book.title, InventoryCode = Books.FindInventoryCodesByISBN(book.id_book_isbn), Authors = Convert(Books.FindAutorsByISBN(book.id_book_isbn)) }; } return(bookInformation); }
public void EditBook(BookInformation bookInformation) { if (bookInformation == null) { throw new ArgumentNullException(nameof(bookInformation)); } Book book = new Book(); Library.EditBook(book); Library.Save(); }
private static BookInformation[] Convert(Book[] books) { if (books == null) { return(null); } BookInformation[] bookInformations = new BookInformation[books.Length]; for (int i = 0; i < books.Length; ++i) { bookInformations[i] = Convert(books[i]); } return(bookInformations); }
public void AddBook(BookInformation bookInformation) { if (bookInformation == null) { throw new ArgumentNullException(nameof(bookInformation)); } Book book = new Book() { annotation = bookInformation.Annotation, book_series = bookInformation.BookSeries, date_publish = bookInformation.PublishDate, full_title = bookInformation.FullTitle, title = bookInformation.Title, id_book_isbn = bookInformation.ISBN, PublishingHouse = new PublishingHouse() { name = bookInformation.PublishHouse.Name, category = bookInformation.PublishHouse.Category, location = bookInformation.PublishHouse.Location }, language = bookInformation.Language, Subject = new Subject() { name = bookInformation.Subject.Name } }; List <Author> authors = new List <Author>(); foreach (var author in bookInformation.Authors) { authors.Add(new Author() { Name = author.Name }); } Library.AddBook(book, authors, bookInformation.InventoryCode.Keys); Library.Save(); }