public bool ExportReport(DbContext dbContext) { var dbDataExtractor = new ReportsDataExtractor(); var salesList = dbDataExtractor.GetData(dbContext); var salesReport = new SalesReport() { Sales = salesList }; Directory.CreateDirectory(@"..\\..\\..\\Files\\XmlReports"); using (var fileStream = File.Create(@"..\\..\\..\\Files\\XmlReports\\report.xml")) { var xmlSerializer = new XmlSerializer(typeof(SalesReport)); xmlSerializer.Serialize(fileStream, salesReport); } return true; }
public bool ExportReport(DbContext dbContext) { var dbDataExtractor = new ReportsDataExtractor(); var salesList = dbDataExtractor.GetData(dbContext); var salesReport = new SalesReport() { Sales = salesList }; Directory.CreateDirectory(@"..\\..\\..\\Files\\JsonReports"); foreach(var report in salesReport.Sales) { var salesReportAsJson = JsonConvert.SerializeObject(report, Formatting.Indented); File.WriteAllText(@"..\\..\\..\\Files\\JsonReports\\report" + "-" + report.ID + ".json", salesReportAsJson); } return true; }
public void CreateSalesReport() { var dataExtractor = new ReportsDataExtractor(); var reportsList = dataExtractor.GetData(this.DbContext); this.Report = new SalesReport() { Sales = reportsList }; }