public ActionResult ReportTypes() { var model = new ReportTypesViewModel(); return(View(model)); }
public ActionResult DownloadReport(ReportTypesViewModel reportTypesViewModel) { //Don't ever put generated reports into the session or into the cache. string reportSelected = reportTypesViewModel.VariousReportExamples; byte[] fileContents = null; string extension = null; string appType = null; switch (reportSelected) { case Employment.Web.Mvc.Area.Example.Types.ReportTypes.BasicPdf: fileContents = createBasicReport().Save(ExportFormat.PDF); extension = ".pdf"; appType = "application/pdf"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.BasicRtf: fileContents = createBasicReport().Save(ExportFormat.RTF); extension = ".rtf"; appType = "application/rtf"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.BasicHtml: fileContents = createBasicReport().Save(ExportFormat.HTML); extension = ".html"; appType = "text/html"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.BasicDocx: fileContents = createBasicReport().Save(ExportFormat.DOCX); extension = ".docx"; appType = "application/msword"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.ComplexPdf: fileContents = createComplexReport().Save(ExportFormat.PDF); extension = ".pdf"; appType = "application/pdf"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.ComplexRtf: fileContents = createComplexReport().Save(ExportFormat.RTF); extension = ".rtf"; appType = "application/rtf"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.ComplexHtml: fileContents = createComplexReport().Save(ExportFormat.HTML); extension = ".html"; appType = "text/html"; break; case Employment.Web.Mvc.Area.Example.Types.ReportTypes.ComplexDocx: fileContents = createComplexReport().Save(ExportFormat.DOCX); extension = ".docx"; appType = "application/msword"; break; } string fileDownloadName = string.IsNullOrEmpty(reportSelected) ? "Report" : string.Format("{0}", reportSelected); return(File(fileContents, appType, fileDownloadName + extension)); }