public ActionResult CreateReport(ReportViewModel reportViewModel) { try { var newReport = reportViewModel.MapTo<ReportViewModel, Report>(); //Checking consistency between column Name and Labels CheckColumnsConfig(reportViewModel.Query, reportViewModel.ColumnLabels, reportViewModel.OutPut); newReport.ColumnLabels = AdjustColumnLabels(reportViewModel).GetCommaSeparatedTokens(); newReport.SubReports = ParseSubReports(reportViewModel.SubReportIds, reportViewModel.SubReportColumns, reportViewModel.IndexParamNames); _virtualOfficeToolManager.AddReport(newReport); return RedirectToAction("Index"); } catch (Exception exception) { ModelState.AddModelError("", string.Format("Errors while trying to add a new Report. Please, try again! More details:{0}", exception.Message)); return View("CreateReport", reportViewModel); } }
public ActionResult ExecuteEditReport(ReportViewModel reportViewModel) { try { ////Removing the Parsing on Column Names //reportViewModel.OutPut = UnParseColumnName(reportViewModel.OutPut); //reportViewModel.UserFilters = UnParseColumnName(reportViewModel.UserFilters); var newReport = reportViewModel.MapTo<ReportViewModel, Report>(); //Checking consistency between column Name and Labels CheckColumnsConfig(reportViewModel.Query, reportViewModel.ColumnLabels, reportViewModel.OutPut); newReport.ColumnLabels = AdjustColumnLabels(reportViewModel).GetCommaSeparatedTokens(); newReport.SubReports = ParseSubReports(reportViewModel.SubReportIds, reportViewModel.SubReportColumns, reportViewModel.IndexParamNames); //If the columns are completely empty it's because they were not modified so the old one is kept if (string.IsNullOrEmpty(newReport.OutPut)) { var report = _virtualOfficeToolManager.GetReport(newReport.Id); newReport.OutPut = report.OutPut; } _virtualOfficeToolManager.UpdateReport(newReport); return RedirectToAction("Index"); } catch (Exception exception) { ModelState.AddModelError("", string.Format("Errors while trying to add a new Report. Please, try again! More details:{0}", exception.Message)); return View("EditReport", reportViewModel); } }