public ActionResult AddMapComponent(MapComponentViewModel mapcomp)
        {
            ActionResult result;
            Map          map = m_repo.GetMap(mapcomp.MapId);

            ViewBag.GenusId = map.GenusId;
            Genus genus = map.Genus;

            ViewBag.GenusId = genus.Id;
            ViewBag.Virus1  = genus.VirusLabel1;
            ViewBag.Virus2  = genus.VirusLabel2;
            ViewBag.Virus3  = genus.VirusLabel3;
            ViewBag.Virus4  = genus.VirusLabel4;

            if (ModelState.IsValid)
            {
                map_repo.Save(mapcomp);
                result = PartialView("_MapComponentRow", mapcomp);
            }
            else
            {
                result = PartialView("_MapComponent", mapcomp);
            }

            return(result);
        }
Beispiel #2
0
        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);
        }
        private MapComponent GetMapComponentFromViewModel(MapComponentViewModel mapcomponentvm)
        {
            MapComponent mapcomponent = null;

            if (mapcomponentvm.Id > 0)
            {
                ValidateMapComponentGenotype(mapcomponentvm.Id, mapcomponentvm.GenotypeId);
                mapcomponent = u_repo.GetMapComponent(mapcomponentvm.Id);
                mapcomponentvm.ToMapComponent(mapcomponent);
            }
            else
            {
                mapcomponent           = mapcomponentvm.ToMapComponent();
                mapcomponent.isRemoved = false;
            }


            if (mapcomponent.GenotypeId.HasValue)
            {
                mapcomponent.Genotype = u_repo.GetGenotype(mapcomponent.GenotypeId.Value);
            }

            if (mapcomponent.Map == null)
            {
                mapcomponent.Map = u_repo.GetMap(mapcomponent.MapId);
            }


            return(mapcomponent);
        }
        public ActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Map map = m_repo.GetMap(id.Value);

            if (map == null)
            {
                return(HttpNotFound());
            }

            ViewBag.MapComponents = m_repo.GetMapComponents(map.Id);

            var crossTypes = m_repo.GetCrossTypes().Where(t => t.GenusId == map.GenusId && t.Retired == false);

            ViewBag.CrossTypes = new SelectList(crossTypes, "Id", "Name");
            map.Questions      = map.Questions.OrderBy(q => q.Order).ToList();
            map.MapComponents  = map.MapComponents.OrderBy(t => t.Row).ThenBy(t => t.PlantNum).ToList();
            return(View(map));
        }
Beispiel #5
0
        public PhenotypeEntryViewModel GetPhenotypeEntryVM(int id, string year)
        {
            Map         map           = u_repo.GetMap(id);
            List <Fate> possibleFates = u_repo.GetFates().OrderBy(t => t.Order).ToList();
            Years       mapYear;

            if (year.IsNullOrWhiteSpace())
            {
                mapYear = map.Years.OrderByDescending(t => t.Year).FirstOrDefault();
            }
            else
            {
                mapYear = map.Years.SingleOrDefault(t => t.Year == year);
            }
            if (mapYear == null || mapYear.Id <= 0)
            {
                throw new PhenotypeException(Properties.Settings.Default.ExceptionPhenotypeInvalidYear);
            }

            PhenotypeEntryViewModel vm = GetPhenotypeEntryVM(map, possibleFates, mapYear.Id);

            return(vm);
        }
Beispiel #6
0
        public ActionResult Edit(int?mapId, string year)
        {
            // year has a string replace and default value in the view, this handles that. TODO: Find a better way.
            if (!mapId.HasValue || year == "yearPlaceHolder" || year == null)
            {
                return(RedirectToAction("Index", "Default", new { area = "Maps" }));
            }
            var map = m_repo.GetMap(mapId.Value);

            if (map == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var vm = p_repo.GetPhenotypeEntryVM(mapId.Value, year);

            return(View(vm));
        }