Ejemplo n.º 1
0
        public ActionResult Index()
        {
            List <ListAuthor> list = new List <ListAuthor>();

            foreach (Author author in database.Authors.ToList())
            {
                ListAuthor x = new ListAuthor(author);
                foreach (Book book in database.Books.ToList())
                {
                    if (book.AuthorID == author.Id)
                    {
                        x.BookCounter++;
                    }
                }
                list.Add(x);
            }
            return(View(list));
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Handles a request
            /// </summary>
            /// <param name="request">The request</param>
            /// <param name="cancellationToken">Cancellation token</param>
            /// <returns>
            /// Response from the request
            /// </returns>
            public async Task <ICollection <BookAuthorDto> > Handle(ListAuthor request, CancellationToken cancellationToken)
            {
                var authors = await _context.BookAuthor.ToListAsync();

                return(_mapper.Map <ICollection <BookAuthor>, ICollection <BookAuthorDto> >(authors));
            }