Esempio n. 1
0
        public List <AuthorFullNameViewModel> GetAuthors()
        {
            var mapperAuthor = new AutoMapperForAuthor();
            List <AuthorFullNameViewModel> authorView = mapperAuthor.Mapp(_authorRepository.GetAll()).ToList();

            return(authorView);
        }
Esempio n. 2
0
        private List <AuthorInBook> GetAuthorInBook(AuthorUpdateViewModel bookView /*, IEnumerable<int> authorId*/)
        {
            var    authorInBook = new List <AuthorInBook>();
            var    mapper       = new AutoMapperForAuthor();
            Author author       = mapper.Mapp(bookView);

            authorInBook.Add(new AuthorInBook {
                Author = author
            });
            return(authorInBook);
        }
Esempio n. 3
0
        public AuthorUpdateViewModel GetAuthor(int id)
        {
            Author authorRepository          = _authorRepository.Get(id);
            var    mapp                      = new AutoMapperForAuthor();
            AuthorUpdateViewModel authorView = mapp.Mapp(authorRepository);

            //List<AuthorInBook> authors = _authorInBookRepository.GetAuthor(id).ToList();
            //var authorView = new AuthorGetViewModel();
            //if (authors != null)
            //{
            //    authorView = authors.GroupBy(x => x.Author.Id).Select(x => new AuthorGetViewModel()
            //    {
            //        Author = x.First().Author,
            //        Books = x.Select(a => a.Book).ToList()
            //    }).First();
            //}
            return(authorView);
        }