Example #1
0
        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);
        }
        // GET: CrossTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            CrossType crossType = m_repo.GetCrossType(id.Value);

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

            return(View(crossType));
        }
Example #3
0
        private void updateAccession(AccessionViewModel accession)
        {
            // update genotype information
            Genotype oldGenotype     = u_repo.GetGenotype(accession.Id);
            var      oldGivenName    = oldGenotype.GivenName;
            var      oldOriginalName = oldGenotype.OriginalName;

            Genotype genotype = accession.ToGenotype();

            genotype.Family       = oldGenotype.Family;
            genotype.FamilyId     = oldGenotype.FamilyId;
            genotype.CrossPlanId  = oldGenotype.CrossPlanId;
            genotype.IsPopulation = accession.IsPopulation;


            if (accession.Id <= 0)
            {
                genotype.Family = u_repo.GetFamily(genotype.FamilyId);
            }

            if (accession.IsBase)
            {
                genotype.Year   = accession.FamilyBaseGenotypeYear;
                genotype.Note   = accession.FamilyBaseGenotypeNote;
                genotype.IsRoot = true;
            }


            if (genotype.GivenName != oldGivenName && !oldGivenName.IsNullOrWhiteSpace())
            {
                genotype.Alias2 = genotype.Alias1;
                genotype.Alias1 = oldGivenName;
            }

            // update family information
            if (accession.IsBase)
            {
                Family oldFamily = u_repo.GetFamily(accession.FamilyId);
                // check origin name and cross number

                Family family = accession.ToFamily();
                if (family.CrossTypeId.HasValue)
                {
                    family.CrossType = u_repo.GetCrossType(accession.FamilyCrossTypeId.Value);
                }

                if (family.OriginId.HasValue)
                {
                    family.Origin = u_repo.GetOrigin(accession.FamilyOriginId.Value);
                }

                if (oldFamily.OriginalName != family.OriginalName && !oldFamily.OriginalName.IsNullOrWhiteSpace())
                {
                    genotype.Alias2 = genotype.Alias1;
                    genotype.Alias1 = oldOriginalName;
                    u_repo.UpdateGeotypesAlias(family.Id, oldOriginalName);
                }

                family.BaseGenotype   = oldFamily.BaseGenotype;
                family.BaseGenotypeId = oldFamily.BaseGenotypeId;
                family.Genus          = oldFamily.Genus;
                family.Genotypes      = oldFamily.Genotypes;
                if (family.FemaleParent.HasValue)
                {
                    family.FemaleGenotype = u_repo.GetGenotype(family.FemaleParent.Value);
                }
                if (family.MaleParent.HasValue)
                {
                    family.MaleGenotype = u_repo.GetGenotype(family.MaleParent.Value);
                }

                if (family.OriginId.HasValue)
                {
                    family.Origin = u_repo.GetOrigin(family.OriginId.Value);
                }
                u_repo.SaveFamily(family);
            }
            u_repo.SaveGenotype(genotype);

            if (genotype.CrossPlanId.HasValue)
            {
                UpdateCrossPlanFromAccession(genotype);
            }
        }