Beispiel #1
0
        public GetAuthorView GetAll()
        {
            var allAuthorsBooksViewModel = new GetAuthorView();

            List <Author> allAuthorsModel = _authorRepository.GetAll();
            List <AuthorGetAuthorViewItem> allAuthorsViewModel = Mapper.Map <List <Author>, List <AuthorGetAuthorViewItem> >(allAuthorsModel);

            List <Book> allBooksModel = _bookRepository.GetAll();
            List <BookGetAuthorViewItem> allBooksViewModel = Mapper.Map <List <Book>, List <BookGetAuthorViewItem> >(allBooksModel);

            foreach (var author in allAuthorsViewModel)
            {
                List <BookAuthor> authorBooks = _bookInAuthorRepository.GetAllByAuthorId(author.Id);
                var books = new List <BookGetAuthorViewItem>();
                foreach (var authorBook in authorBooks)
                {
                    if (authorBook.Book != null)
                    {
                        books.Add(Mapper.Map <Book, BookGetAuthorViewItem>(authorBook.Book));
                    }
                }
                author.Books = books;
            }
            allAuthorsBooksViewModel.Authors  = allAuthorsViewModel;
            allAuthorsBooksViewModel.AllBooks = allBooksViewModel;

            return(allAuthorsBooksViewModel);
        }
        public IEnumerable <GetPublicationView> GetPublicationsNotExistInAuthor(GetAuthorView author)
        {
            var authorsMapped      = Mapper.Map <GetAuthorView, Author>(author);
            var publications       = authorsRepository.GetPublicationsNotExistInAuthor(authorsMapped);
            var publicationsMapped = Mapper.Map <IEnumerable <Publication>, IEnumerable <GetPublicationView> >(publications);

            return(publicationsMapped);
        }
        public IEnumerable <GetMagazineView> GetMagazinesNotExistInAuthor(GetAuthorView author)
        {
            var authorsMapped   = Mapper.Map <GetAuthorView, Author>(author);
            var magazines       = authorsRepository.GetMagazinesNotExistInAuthor(authorsMapped);
            var magazinesMapped = Mapper.Map <IEnumerable <Magazine>, IEnumerable <GetMagazineView> >(magazines);

            return(magazinesMapped);
        }
        public IEnumerable <GetBookView> GetBooksNotExistInAuthor(GetAuthorView author)
        {
            var authorsMapped = Mapper.Map <GetAuthorView, Author>(author);
            var books         = authorsRepository.GetBooksNotExistInAuthor(authorsMapped);
            var booksMapped   = Mapper.Map <IEnumerable <Book>, IEnumerable <GetBookView> >(books);

            return(booksMapped);
        }
        public IEnumerable <GetArticleView> GetArticlesNotExistInAuthor(GetAuthorView author)
        {
            var authorsMapped  = Mapper.Map <GetAuthorView, Author>(author);
            var articles       = authorsRepository.GetArticlesNotExistInAuthor(authorsMapped);
            var articlesMapped = Mapper.Map <IEnumerable <Article>, IEnumerable <GetArticleView> >(articles);

            return(articlesMapped);
        }
        public /*async*/ void Update(GetAuthorView authorView)
        {
            var authors = Mapper.Map <GetAuthorView, Author>(authorView);

            /*await*/ authorsRepository.Update(authors);
        }
Beispiel #7
0
        public GetAuthorView Get()
        {
            GetAuthorView authorsBooksViewModel = _authorService.GetAll();

            return(authorsBooksViewModel);
        }