public IHttpActionResult GetData([FromBody] ExportDataRequest request) { if (_exportSecurityHandlerRegistrar.GetHandler(request.ExportTypeName + "ExportDataPolicy")?.Authorize(User.Identity.Name, request) != true) { return(Unauthorized()); } var exportedTypeDefinition = _knownExportTypesResolver.ResolveExportedTypeDefinition(request.ExportTypeName); var pagedDataSource = exportedTypeDefinition.ExportedDataSourceFactory(request.DataQuery); pagedDataSource.Fetch(); var queryResult = pagedDataSource.Items; var result = new ExportableSearchResult() { TotalCount = pagedDataSource.GetTotalCount(), Results = queryResult.ToList() }; return(Ok(result)); }
public async Task <ActionResult <ExportableSearchResult> > GetData([FromBody] ExportDataRequest request) { var authorizationResult = await _authorizationService.AuthorizeAsync(User, request.DataQuery, request.ExportTypeName + "ExportDataPolicy"); if (!authorizationResult.Succeeded) { return(Unauthorized()); } var exportedTypeDefinition = _knownExportTypesResolver.ResolveExportedTypeDefinition(request.ExportTypeName); var pagedDataSource = (exportedTypeDefinition.DataSourceFactory ?? throw new ArgumentNullException(nameof(ExportedTypeDefinition.DataSourceFactory))).Create(request.DataQuery); pagedDataSource.Fetch(); var queryResult = pagedDataSource.Items; var result = new ExportableSearchResult() { TotalCount = pagedDataSource.GetTotalCount(), Results = queryResult.ToList() }; return(Ok(result)); }