public async Task <QueryResultDTO <PostDTO> > Handle(GetAdminQueryCommand request, CancellationToken ct) { var query = new QueryObject() { Search = request.Search, SearchBy = QueryParser.ParseSearch(request.SearchBy), Filters = QueryParser.ParseFilter(request.Filters), SortBy = request.SortBy == null ? "DateCreated" : request.SortBy, IsSortAscending = request.IsSortAscending, Page = request.Page, PageSize = request.PageSize }; var result = await postRepository.GetQueryResultAsync(query, ct, (Post p) => new PostDTO { Id = p.Id, Title = p.Title, DateCreated = p.DateCreated, DateLastUpdated = p.DateLastUpdated }); return(new QueryResultDTO <PostDTO>() { TotalItems = result.TotalItems, Items = result.Items }); }
public async Task <IActionResult> GetAdminPosts(GetAdminQueryCommand command) { return(Ok(await mediator.Send(command))); }