public async Task <ActionResult> Index()
        {
            var dashboardViewModel = new DashboardViewModel()
            {
                TopBooksByPrice     = await _bookServices.GetAsync(orderBy : x => x.OrderByDescending(b => b.Price), page : 1, pageSize : 3),
                TopCategoriesByBook = await _categoryService.GetAsync(orderBy : x => x.OrderByDescending(b => b.Books.Count), page : 1, pageSize : 3),
                TopAuthorsByBook    = await _authorService.GetAsync(orderBy : x => x.OrderByDescending(b => b.Books.Count), page : 1, pageSize : 3),
                TopPublishersByBook = await _publisherService.GetAsync(orderBy : x => x.OrderByDescending(b => b.Books.Count), page : 1, pageSize : 3),
                TopBooksByComment   = await _bookServices.GetAsync(orderBy : x => x.OrderByDescending(b => b.Reviews.Count), page : 1, pageSize : 3),
                TotalBooks          = await _bookServices.CountAsync(),
                TotalCategories     = await _categoryService.CountAsync(),
                TotalAuthors        = await _authorService.CountAsync(),
                TotalPublishers     = await _publisherService.CountAsync(),
                TotalComments       = await _bookReviewService.CountAsync(),
            };

            return(View(dashboardViewModel));
        }
示例#2
0
        public async Task <PagedResponse <FoundPublisherDTO> > Handle(SearchPublisherQuery request, CancellationToken cancellationToken)
        {
            PublisherSearchCondition searchCondition = new PublisherSearchCondition()
            {
                Name          = GetFilterValues(request.SearchCondition.Name),
                Page          = request.SearchCondition.Page,
                PageSize      = request.SearchCondition.PageSize,
                SortDirection = request.SearchCondition.SortDirection,
                SortProperty  = request.SearchCondition.SortProperty
            };

            var sortProperty = GetSortProperty(searchCondition.SortProperty);
            IReadOnlyCollection <Publisher> foundPublisher = await publisherService.FindAsync(searchCondition, sortProperty);

            FoundPublisherDTO[] mappedPublisher = foundPublisher.Select(MapToFoundPublisherDTO).ToArray();
            var totalCount = await publisherService.CountAsync(searchCondition);

            return(new PagedResponse <FoundPublisherDTO>
            {
                Items = mappedPublisher,
                TotalCount = totalCount
            });
        }