private async Task <MovieSearchResponse> ExecuteMovieSearchHelperAsync(String title) { //Execute the Move Search to load data . . . //NOTE: This can come from any source, and can be from converted JSON or Xml, etc. //NOTE: As an interesting use case here, we load the results dynamically from a Movie Search // Database REST call for JSON results, and convert to Xml dynamically to use efficiently // with our templates. var movieSearchService = new MovieSearchService(); var searchResponse = await movieSearchService.SearchAsync(title).ConfigureAwait(false); return(searchResponse); }
public async Task <ActionResult> PdfWithXslt(String title = "Star Wars") { //Execute the Move Search to load data . . . //NOTE: This can come from any source, and can be from converted JSON or Xml, etc. //NOTE: As an interesting use case here, we load the results dynamically from a Movie Search // Database REST call for JSON results, and convert to Xml dynamically to use efficiently // with our templates. var movieSearchService = new MovieSearchService(); var searchResponse = await movieSearchService.SearchAsync(title); //Initialize the appropriate Renderer based on the Parameter. // and execute the Pdf Renderer to generate the Pdf Document byte data IPdfTemplatingRenderer <MovieSearchResponse> pdfTemplatingRenderer = new XsltMoviePdfRenderer(); var pdfBytes = pdfTemplatingRenderer.RenderPdf(searchResponse); //Create the File Content Result from the Pdf byte data var fileContent = new FileContentResult(pdfBytes, "application/pdf"); return(fileContent); }