public IActionResult ExportAsJson([FromBody] ElasticSearchRequest request) { IEnumerable <ScrapedComment> history = CommentScraper.All(request.Query, request.Sort).Data; byte[] serialized = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(history)); return(File(serialized, "application/json-download", "export.json")); }
public IActionResult ExportAsCSV([FromBody] ElasticSearchRequest request) { IEnumerable <ScrapedComment> history = CommentScraper.All(request.Query, request.Sort).Data; byte[] serialized = CsvSerialization.Serialize(history, CsvSerialization.MapComment); return(File(serialized, "text/csv", "export.csv")); }