public MapViewReportViewModel GetMapViewReportViewModel(int?mapId, string year = null) { MapViewReportViewModel vm = new MapViewReportViewModel(); if (mapId.HasValue || year != null) { Map map = u_repo.GetMap(mapId.Value); if (year == null && map != null) { year = map.Years.Max(t => int.Parse(t.Year)).ToString(); } vm.MapId = map.Id; vm.MapName = map.Name; vm.MapFullName = map.FullName; vm.MapYear = year; vm.MapPlantedYear = map.PlantingYear; vm.MapIsSeedling = map.IsSeedlingMap; if (map.IsSeedlingMap) { vm.SeedlingComponentValue = "Planted"; } } return(vm); }
public static ReportViewModel ToReportViewModel(this MapViewReportViewModel vm, string reportName, string reportTitle) { //TODO ?: Create report attribute for Report View models and use reflection to build the report params dynamically string paramMapId = "MapId"; string paramMapYear = "Year"; string paramMapName = "MapName"; string paramPrintPick = "ShowPicking"; string paramMapComponentSeedling = "MapComponentSeedlingFlag"; string paramReportTitle = "ReportTitle"; bool? seedlingMC = null; if (vm.SeedlingComponentValue == "Planted") { seedlingMC = true; } else if (vm.SeedlingComponentValue == "SelectionsMade") { seedlingMC = false; } List <ReportParameter> reportparameters = new List <ReportParameter>(); reportparameters.Add(new ReportParameter(paramMapId, vm.MapId.ToString())); reportparameters.Add(new ReportParameter(paramMapYear, vm.MapYear)); reportparameters.Add(new ReportParameter(paramMapName, vm.MapName)); reportparameters.Add(new ReportParameter(paramPrintPick, vm.PrintPicking.ToString())); reportparameters.Add(new ReportParameter(paramMapComponentSeedling, seedlingMC.HasValue ? seedlingMC.Value.ToString() : null)); reportparameters.Add(new ReportParameter(paramReportTitle, reportTitle)); return(GetReportViewModel(reportparameters, reportName, reportTitle)); }
public ActionResult MapView(MapViewReportViewModel mapView) { if (!ModelState.IsValid) { return(View(mapView)); } ReportViewModel reportVM = r_repo.GetReportForMapView(mapView); TempData["ReportViewModel"] = reportVM; return(RedirectToAction("ReportView")); }
public ReportViewModel GetReportForMapView(MapViewReportViewModel vm) { string reportName = Properties.Settings.Default.ReportNameMapView; string reportTitle = string.Empty; string optionsTitle = GetMapOptionsTitle(vm.SeedlingComponentValue); if (vm.MapIsSeedling) { reportTitle = string.Format("{0}: Map View {1} {2}", vm.MapFullName, vm.MapYear, optionsTitle); } else { reportTitle = string.Format("{0}: Map View {1} ", vm.MapFullName, vm.MapYear); } return(vm.ToReportViewModel(reportName, reportTitle)); }
public ActionResult MapView(int?mapId, string year = null) { MapViewReportViewModel reportVM = r_repo.GetMapViewReportViewModel(mapId, year); return(View(reportVM)); }