public void Add(PostBookViewModel bookViewModel) { Book book = Mapper.Map <PostBookViewModel, Book>(bookViewModel); _bookRepository.Add(book); bookViewModel.PostBookViewItem.Id = book.Id; var listToAdd = MapToPublicationHouseBook(bookViewModel.PostBookViewItem); _publicationHouseBookRepository.Add(listToAdd); var listAuthorsToAdd = MapToBookAuthor(bookViewModel.PostBookViewItem); _bookAuthorRepository.Add(listAuthorsToAdd); }
private void AddRelationshipsBookAuthor(Book book, List <GetAuthorViewItem> authors) { List <BookAuthor> bookAuthors = new List <BookAuthor>(); foreach (var publisher in authors) { var bookAuthor = new BookAuthor(); bookAuthor.BookId = book.Id; bookAuthor.AuthorId = publisher.Id; bookAuthors.Add(bookAuthor); } _bookAuthorRepository.Add(bookAuthors); }