Example #1
0
        public async Task <BookDetailsViewModelItem> GetBook(int id)
        {
            Book book = await _bookRepository.Get(id);

            List <AuthorBooks> authorBooks = await _authorBooksRepository.GetByBooksId(book.Id);

            List <int> authorsIds = authorBooks.Select(item => item.AuthorId).Distinct().ToList();

            List <Author> authors = await _authorRepository.GetAuthorsByIds(authorsIds);

            List <string> authorsNames = authors.Select(m => m.Name).ToList();

            BookDetailsViewModelItem result = _mapper.Map <BookDetailsViewModelItem>(book);

            result.Authors.AddRange(authorsNames);
            result.Image = await _dropBoxManager.GetFileLink(1);

            return(result);
        }
        public async Task <BookDetailsViewModelItem> GetBook(int id)
        {
            BookDetailsViewModelItem book = await _bookService.GetBook(id);

            return(book);
        }