Esempio n. 1
0
        private static void DeleteTrait(Person selectedPerson, TraitRepository traitRepository, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Trait traitToBeDeleted = GetSelectedPersonsTrait(selectedPerson, traitRepository, personRepository, genotypeRepository, rng, context);

            selectedPerson.Phenotype.Traits.Remove(traitToBeDeleted);
            context.SaveChanges();
        }
Esempio n. 2
0
        private static void DeleteGenotype(Person SelectedPerson, TraitRepository traitRepository, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Genotype genotypeToBeDeleted = GetSelectedPersonsGenotype(SelectedPerson, traitRepository, personRepository, genotypeRepository, rng, context);

            SelectedPerson.Phenotype.TraitGenotypes.Remove(genotypeToBeDeleted);
            context.SaveChanges();

            // context.Genotypes.Remove(); HOW TO REMOVE FROM THE DATABASE
        }
Esempio n. 3
0
        private static void ChangeSex(TraitRepository traitRepository, Person SelectedPerson, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Console.WriteLine("Please input a new sex (Male, Female or Unknown)");
            string inputtedSex = Console.ReadLine();
            Sex    newSex      = (Sex)Enum.Parse(typeof(Sex), inputtedSex, true);

            SelectedPerson.Sex = newSex;
            context.SaveChanges();
            PersonScreen(traitRepository, SelectedPerson, personRepository, genotypeRepository, rng, context); //returns user to last menu
        }
Esempio n. 4
0
        private static void ChangeName(TraitRepository traitRepository, Person SelectedPerson, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Console.WriteLine("Please input a new full name");
            string newName = Console.ReadLine();

            if (newName == "")
            {
                Console.WriteLine("It is against the Geneva convention for a person to be denied a name");
            }

            SelectedPerson.Name = newName;
            context.SaveChanges();
            PersonScreen(traitRepository, SelectedPerson, personRepository, genotypeRepository, rng, context);//returns user to last menu
        }
Esempio n. 5
0
        private static void changeLiving(TraitRepository traitRepository, Person SelectedPerson, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Console.WriteLine("Please input a new Living status (True, False)");
            string acceptableTrueString  = "true";
            string acceptableFalseString = "False";
            string inputtedLiving        = Console.ReadLine();

            if (inputtedLiving == acceptableTrueString || inputtedLiving == acceptableFalseString)
            {
                bool inputLiving = (bool)Convert.ToBoolean(inputtedLiving);
                SelectedPerson.Living = inputLiving;
            }
            context.SaveChanges();
            PersonScreen(traitRepository, SelectedPerson, personRepository, genotypeRepository, rng, context); //returns user to last menu
        }
Esempio n. 6
0
        private static void AddExsistingGenotype(TraitRepository traitRepository, Person SelectedPerson, GenotypeRepository genotypeRepository, PersonRepository personRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Console.Clear();
            Console.WriteLine("Already exsisting Genotypes:");
            int num = 0;

            foreach (var g in genotypeRepository.ListGenotypes())
            {
                Console.WriteLine(num + ") " + g);
                num++;
            }
            Console.WriteLine("Select a genotype from list:");
            int genotypeIndex = Convert.ToInt32(Console.ReadLine());
            var Allgenotypes  = genotypeRepository.ListGenotypes();

            SelectedPerson.AddGenotypeToPerson(Allgenotypes[genotypeIndex]);
            context.SaveChanges();
            PersonScreen(traitRepository, SelectedPerson, personRepository, genotypeRepository, rng, context); //returns user to last menu
        }
Esempio n. 7
0
        private static void AddFather(TraitRepository traitRepository, Person selectedPerson, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            StringBuilder sb = new StringBuilder();

            ListAllPersonsScreen(sb, personRepository, genotypeRepository);
            string s = sb.ToString();

            Console.Write(s);
            Person personToBeFather = FindPersonByIndex(personRepository);
            bool   can = selectedPerson.CanAddFather(personToBeFather);

            if (can)
            {
                selectedPerson.AddFatherToPerson(personToBeFather);
                context.SaveChanges();
                PersonScreen(traitRepository, selectedPerson, personRepository, genotypeRepository, rng, context);
            }
            else
            {
                Console.WriteLine("Only biological males can be entered as biological fathers.");
                Console.ReadLine();
            }
        }
Esempio n. 8
0
        private static void AddExsistingTrait(Person selectedPerson, TraitRepository traitRepository, PersonRepository personRepository, GenotypeRepository genotypeRepository, RealRandomNumberGenerator rng, GeneticCounsellorDbContext context)
        {
            Console.Clear();
            Console.WriteLine("Already exsisting Traits:");
            int num = 0;

            foreach (var t in traitRepository.ListTraits())
            {
                Console.WriteLine(num + ") " + t);
                num++;
            }
            Console.WriteLine("Select a trait from the list:");
            int   traitIndex  = Convert.ToInt32(Console.ReadLine());
            var   allTraits   = traitRepository.ListTraits();
            Trait chosenTrait = allTraits[traitIndex];

            selectedPerson.AddTraitToPerson(chosenTrait);
            Console.WriteLine("Select which genotype to add to person:");
            chosenTrait.GenerateGenotypesForATrait(genotypeRepository);
            AddExsistingGenotype(traitRepository, selectedPerson, genotypeRepository, personRepository, rng, context);
            context.SaveChanges();
            PersonScreen(traitRepository, selectedPerson, personRepository, genotypeRepository, rng, context);
        }