public ActionResult EditReport(Guid reportId) { using (var service = ServiceLocator.Instance.Resolve <IReportService>()) { var report = service.FindReport(reportId); var tableSchemas = this.GetTableSchema(report.Rdbms, report.ReportName); var model = new ReportModifyViewModel { Report = report, TableSchemas = tableSchemas }; this.GetViewBags(); return(PartialView(model)); } }
public ActionResult EditReport(ReportModifyViewModel model, IEnumerable <string> colunms) { try { var creator = this.LoginUser.Identity.Name; var reportDto = model.Report; using (var service = ServiceLocator.Instance.Resolve <IReportService>()) { // modify the report header service.UpdateReportHeader(reportDto.ID, reportDto.DisplayName, reportDto.Description, creator); // modify the report fields (add / remove) var report = service.FindReport(reportDto.ID); var tableSchemas = this.GetTableSchema(report.Rdbms, report.ReportName); // firstly remove all,then add and sort IEnumerable <ReportFieldDto> addingFileds = null; if (colunms != null) { addingFileds = (from table in tableSchemas where colunms.Contains(table.ColunmName) select new ReportFieldDto { FieldName = table.ColunmName, DisplayName = table.ColunmName, DataType = table.DataType, CreatedBy = creator }); } service.SetReportFields(reportDto.ID, addingFileds); } return(Json(true)); } catch (Exception) { return(Json(false, "Update the report failure.")); } }