示例#1
0
        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);
        }
示例#2
0
        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);
        }