public List <AuthorFullNameViewModel> GetAuthors() { var mapperAuthor = new AutoMapperForAuthor(); List <AuthorFullNameViewModel> authorView = mapperAuthor.Mapp(_authorRepository.GetAll()).ToList(); return(authorView); }
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); }
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); }