public async Task <PagedResponse <FoundAuthorDTO> > Handle(SearchAuthorQuery request, CancellationToken cancellationToken) { AuthorSearchCondition searchCondition = new AuthorSearchCondition() { Name = GetFilterValues(request.SearchCondition.Name), Surname = GetFilterValues(request.SearchCondition.Surname), Patronymic = GetFilterValues(request.SearchCondition.Patronymic), Page = request.SearchCondition.Page, PageSize = request.SearchCondition.PageSize, SortDirection = request.SearchCondition.SortDirection, SortProperty = request.SearchCondition.SortProperty }; var sortProperty = GetSortProperty(searchCondition.SortProperty); IReadOnlyCollection <Author> foundAuthor = await authorService.FindAsync(searchCondition, sortProperty); FoundAuthorDTO[] mappedAuthor = foundAuthor.Select(MapToFoundAuthorDTO).ToArray(); var totalCount = await authorService.CountAsync(searchCondition); return(new PagedResponse <FoundAuthorDTO> { Items = mappedAuthor, TotalCount = totalCount }); }
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)); }