private void GetDefaultValues(CrossPlan crossPlan, IPlantBreedingRepo repo) { if (crossPlan.Id > 0 && !crossPlan.GenotypeId.HasValue) { CrossPlan old = repo.GetCrossPlan(crossPlan.Id); if (!crossPlan.GenotypeId.HasValue) { crossPlan.GenotypeId = old.GenotypeId; } } if (crossPlan.FemaleParentId.HasValue && crossPlan.FemaleParent == null) { crossPlan.FemaleParent = repo.GetGenotype(crossPlan.FemaleParentId.Value); } if (crossPlan.MaleParentId.HasValue && crossPlan.MaleParent == null) { crossPlan.MaleParent = repo.GetGenotype(crossPlan.MaleParentId.Value); } if (crossPlan.OriginId.HasValue && crossPlan.OriginId == null) { crossPlan.Origin = repo.GetOrigin(crossPlan.OriginId.Value); } if (crossPlan.CrossTypeId.HasValue && crossPlan.CrossType == null) { crossPlan.CrossType = repo.GetCrossType(crossPlan.CrossTypeId.Value); } crossPlan.Genus = repo.GetGenus(crossPlan.GenusId); }
public AccessionViewModel GetNextAccession(int crossId) { CrossPlan crossPlan = u_repo.GetCrossPlan(crossId); int genusId = crossPlan.GenusId; Origin origin = u_repo.GetDefaultOrigin(); AccessionViewModel accession = a_repo.GetNextAccession(genusId, origin.Id); accession.CopyCrossToAccession(crossPlan); accession.IsBase = true; accession.IsRoot = true; accession.Id = 0; return(accession); }
public void UpdateCrossPlanFromAccession(Genotype genotype) { if (!genotype.CrossPlanId.HasValue) { throw new CrossPlanException(Properties.Settings.Default.ExceptionCrossPlanAccessionNoId); } CrossPlan crossplan = u_repo.GetCrossPlan(genotype.CrossPlanId.Value); if (crossplan != null) { crossplan.UpdateFromAccession(genotype); u_repo.SaveCrossPlan(crossplan); } }