public MapComponentReportViewModel GetMapComponentReportViewModel(int?mapId, string year = null) { MapComponentReportViewModel vm = new MapComponentReportViewModel(); 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.MapIsSeedling = map.IsSeedlingMap; vm.MapPlantedYear = map.PlantingYear; vm.Virus1Label = map.Genus.VirusLabel1; vm.Virus2Label = map.Genus.VirusLabel2; vm.Virus3Label = map.Genus.VirusLabel3; vm.Virus4Label = map.Genus.VirusLabel4; if (map.IsSeedlingMap) { vm.SeedlingComponentValue = "Planted"; } } return(vm); }
public ActionResult MapComponents(MapComponentReportViewModel mapView) { if (!ModelState.IsValid) { return(View(mapView)); } ReportViewModel reportVM = r_repo.GetReportForMapComponent(mapView); TempData["ReportViewModel"] = reportVM; return(RedirectToAction("ReportView")); }
public ReportViewModel GetReportForMapComponent(MapComponentReportViewModel vm) { string reportName = Properties.Settings.Default.ReportNameMapComponent; string reportTitle = string.Empty; string optionsTitle = GetMapOptionsTitle(vm.SeedlingComponentValue); if (vm.MapIsSeedling) { reportTitle = string.Format("{0}: Map Components {1} {2}", vm.MapFullName, vm.MapYear, optionsTitle); } else { reportTitle = string.Format("{0}: Map Components {1} ", vm.MapFullName, vm.MapYear); } return(vm.ToReportViewModel(reportName, reportTitle)); }
public static ReportViewModel ToReportViewModel(this MapComponentReportViewModel 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 virus1Label = "Virus1Label"; string virus2Label = "Virus2Label"; string virus3Label = "Virus3Label"; string virus4Label = "Virus4Label"; string paramReportTitle = "ReportTitle"; string paramMapComponentSeedling = "MapComponentSeedlingFlag"; 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(virus1Label, vm.Virus1Label.GetValueOrBlank())); reportparameters.Add(new ReportParameter(virus2Label, vm.Virus2Label.GetValueOrBlank())); reportparameters.Add(new ReportParameter(virus3Label, vm.Virus3Label.GetValueOrBlank())); reportparameters.Add(new ReportParameter(virus4Label, vm.Virus4Label.GetValueOrBlank())); reportparameters.Add(new ReportParameter(paramMapComponentSeedling, seedlingMC.HasValue ? seedlingMC.Value.ToString() : null)); reportparameters.Add(new ReportParameter(paramReportTitle, reportTitle)); return(GetReportViewModel(reportparameters, reportName, reportTitle)); }
public ActionResult MapComponents(int?mapId, string year = null) { MapComponentReportViewModel reportVM = r_repo.GetMapComponentReportViewModel(mapId, year); return(View(reportVM)); }