Beispiel #1
0
        static void Hatch(IEnumerable <Dinosaurid> dinosaurs)
        {
            string[] names             = { "Amy", "Brian", "Charlie", "Diane" };
            var      random            = new Random((int)DateTime.Now.Ticks);
            var      nameRandomValue   = random.Next(0, 4);
            var      weightRandomValue = random.Next(1, 101);
            var      dietRandomValue   = random.Next(0, 2);
            string   weight            = weightRandomValue.ToString();

            string[] diet     = { "carnivore", "herbivore" };
            var      dinosaur = new Dinosaurid();

            dinosaur.Name         = names[nameRandomValue];
            dinosaur.DietType     = diet[dietRandomValue];
            dinosaur.Weight       = weight;
            dinosaur.DateAcquired = DateTime.Now;
            Db.Dinosaurids.Add(dinosaur);
            Db.SaveChanges();
        }
Beispiel #2
0
        static void AddDinosaur()
        {
            Console.WriteLine("What Dinosaur would you like to add?");
            var dinosaurName = Console.ReadLine();

            Console.WriteLine("Is the Dinosaur a carnivore or herbivore?");
            var dietType = Console.ReadLine();

            Console.WriteLine("What is the Dinosaur's weight?");
            var dinosaurWeight = Console.ReadLine();

            Console.WriteLine("What pen number is the dinosaur being kept?");
            var enclosureNumber = Console.ReadLine();
            var dinosaur        = new Dinosaurid();

            dinosaur.Name            = dinosaurName;
            dinosaur.DietType        = dietType;
            dinosaur.Weight          = dinosaurWeight;
            dinosaur.EnclosureNumber = enclosureNumber;
            dinosaur.DateAcquired    = DateTime.Now;
            // Dinosaurs.Add(dinosaur);
            Db.Dinosaurids.Add(dinosaur);
            Db.SaveChanges();
        }