Exemplo n.º 1
0
        public List <BookTitleViewModel> GetBooks()
        {
            var mapperAuthor = new AutoMapperForBook();
            List <BookTitleViewModel> authorView = mapperAuthor.Mapp(_bookRepository.GetAll()).ToList();

            return(authorView);
        }
Exemplo n.º 2
0
        private List <AuthorInBook> GetAuthorInBook(BookUpdateViewModel bookView, IEnumerable <int> authorId)
        {
            var  authorInBook = new List <AuthorInBook>();
            var  mapper       = new AutoMapperForBook();
            Book book         = mapper.Mapp(bookView);

            if (authorId != null)
            {
                foreach (int id in authorId)
                {
                    Author author = _authorRepository.Get(id);
                    authorInBook.Add(new AuthorInBook
                    {
                        Author = author,
                        Book   = book
                    });
                }
            }

            if (authorId == null)
            {
                authorInBook.Add(new AuthorInBook {
                    Book = book
                });
            }
            return(authorInBook);
        }