コード例 #1
0
        public ReportViewModel GetReportForCrossPlanLocation(CrossPlanLocationReportViewModel vm)
        {
            string reportName = Properties.Settings.Default.ReportNameCrossPlanLocation;

            if (vm.GenusId.HasValue)
            {
                vm.GenusValue = u_repo.GetGenus(vm.GenusId.Value).Value;
            }

            string reportTitle = string.Format("{0} {1} Cross Locations", vm.Year, vm.GenusValue);

            return(vm.ToReportViewModel(reportName, reportTitle));
        }
コード例 #2
0
        public ActionResult CrossPlanLocation(CrossPlanLocationReportViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.genus = new SelectList(m_repo.GetAllGenera(), "Id", "Value", vm.GenusId);
                return(View(vm));
            }

            ReportViewModel reportVM = r_repo.GetReportForCrossPlanLocation(vm);

            TempData["ReportViewModel"] = reportVM;

            return(RedirectToAction("ReportView"));
        }
コード例 #3
0
        public ActionResult CrossPlanLocation(string year, int?genus)
        {
            if (!genus.HasValue)
            {
                genus = SessionManager.GetGenusId();
            }

            if (year == null)
            {
                year = DateTime.Now.Year.ToString();
            }

            CrossPlanLocationReportViewModel vm = r_repo.GetCrossPlanLocationReportViewModel(genus, year);

            ViewBag.genus = new SelectList(m_repo.GetAllGenera(), "Id", "Value", vm.GenusId);

            return(View(vm));
        }
コード例 #4
0
        public CrossPlanLocationReportViewModel GetCrossPlanLocationReportViewModel(int?genusId, string year)
        {
            CrossPlanLocationReportViewModel vm = new CrossPlanLocationReportViewModel();

            if (genusId.HasValue)
            {
                Genus genus = u_repo.GetGenus(genusId.Value);
                vm.GenusId     = genus.Id;
                vm.GenusName   = genus.Name;
                vm.Virus1Label = genus.VirusLabel1;
                vm.Virus2Label = genus.VirusLabel2;
                vm.Virus3Label = genus.VirusLabel3;
                vm.Virus4Label = genus.VirusLabel4;
            }

            vm.Year = year;

            return(vm);
        }
        public static ReportViewModel ToReportViewModel(this CrossPlanLocationReportViewModel vm, string reportName, string reportTitle)
        {
            //TODO ?: Create report attribute for Report View models and use reflection to build the report params dynamically
            string paramGenusId     = "GenusId";
            string paramYear        = "Year";
            string paramReportTitle = "ReportTitle";
            string virus1Label      = "VirusLabel1";
            string virus2Label      = "VirusLabel2";
            string virus3Label      = "VirusLabel3";
            string virus4Label      = "VirusLabel4";


            List <ReportParameter> reportparameters = new List <ReportParameter>();

            reportparameters.Add(new ReportParameter(paramGenusId, vm.GenusId.ToString()));
            reportparameters.Add(new ReportParameter(paramYear, vm.Year));
            reportparameters.Add(new ReportParameter(paramReportTitle, reportTitle));
            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()));

            return(GetReportViewModel(reportparameters, reportName, reportTitle));
        }