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); }
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())); }
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)); } }
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); }