Beispiel #1
0
        private MapComponentYears CreateMapComponent(SeedlingViewModel seedlingViewModel, Genotype genotype, Map map)
        {
            MapComponent newSeedling = new MapComponent()
            {
                GenotypeId = genotype.Id,
                Genotype   = genotype,
                MapId      = map.Id,
                Map        = map,
                Row        = seedlingViewModel.RowNum,
                PlantNum   = seedlingViewModel.PlantNum,
                isSeedling = false
            };

            u_repo.SaveMapComponent(newSeedling);

            MapComponentYears mapComponentYear = new MapComponentYears()
            {
                Answers        = new List <Answer>(),
                YearsId        = seedlingViewModel.MapYearId,
                MapComponentId = newSeedling.Id,
                MapComponent   = newSeedling
            };

            u_repo.SaveMapComponentYear(mapComponentYear);
            return(mapComponentYear);
        }
Beispiel #2
0
        public MapComponentSummaryVM CreateSeedlingSelection(SeedlingViewModel seedlingViewModel)
        {
            var map = u_repo.GetMap(seedlingViewModel.MapId);

            MapComponentYears            mapcomp      = SaveSeedling(seedlingViewModel, map);
            MapComponentSummaryViewModel mapSummaryVM = mapcomp.ToMapComponentSummaryViewModel();

            mapSummaryVM.PossibleFates = u_repo.GetFates().ToSelectList(t => t.Id.ToString(), t => t.Name, t => false);

            return(PhenotypeEntryRowFull(mapcomp, map.Questions.ToList()));
        }
Beispiel #3
0
 public ActionResult CreateSeedlingRow(SeedlingViewModel seedlingViewModel)
 {
     try
     {
         var           mapComponentSummaryVM = p_repo.CreateSeedlingSelection(seedlingViewModel);
         JsonNetResult jsonNetResult         = new JsonNetResult();
         jsonNetResult.Data = mapComponentSummaryVM;
         jsonNetResult.SerializerSettings.DateFormatString = "yyyy-MM-dd";
         return(jsonNetResult);
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, e.Message));
     }
 }
Beispiel #4
0
        private MapComponentYears SaveSeedling(SeedlingViewModel seedlingViewModel, Map map)
        {
            Genotype seedlingGen = u_repo.GetGenotype(seedlingViewModel.GenotypeId);

            if (seedlingGen == null)
            {
                throw new PhenotypeException("No Accession specified");
            }

            var               year        = u_repo.GetYear(seedlingViewModel.MapYearId);
            Genotype          selection   = CreateGenotypeSelection(seedlingViewModel.GenotypeId, year.Year, seedlingViewModel.CreatedDate);
            MapComponentYears newSeedling = CreateMapComponent(seedlingViewModel, selection, map);

            return(newSeedling);
        }