Beispiel #1
0
        public static void GenerateData(BirthClinicDbContext Context)
        {
            //Adding 136 Births since there are 5000 births per year (13.6 per day), and we want to simulate 10 days of fake data.
            for (int i = 0; i < HowManyBirthsToGenerate; i++)
            {
                var B = BirthFactory.CreateFakeBirth();
                if (!CreateReservations(Context, B, out List <Reservation> reservations))
                {
                    Console.WriteLine("We are out of rooms");
                    continue;
                }
                if (!AddClinicians(Context, B, out List <Clinician> Clinicians))
                {
                    continue;
                }

                Context.AddRange(reservations);

                B.AssociatedClinicians = Clinicians;
                B.Mother = AddMother();
                Random rand = new();
                if (rand.Next(1, 10) > 1)
                {
                    B.Father = AddFather();
                }
                B.Relatives = AddRelatives();

                B.ChildrenToBeBorn = AddChildrenToBorn();

                B.IsEnded = false;

                Context.Births.Add(B);
                Context.SaveChanges();
            }
        }
Beispiel #2
0
        public static bool CreateBirth(BirthClinicDbContext Context)
        {
            var B = BirthFactory.CreateFakeBirth();

            if (!CreateReservations(Context, B, out List <Reservation> reservations))
            {
                Console.WriteLine("We are out of rooms");
                return(false);
            }
            if (!AddClinicians(Context, B, out List <Clinician> Clinicians))
            {
                return(false);
            }

            Context.AddRange(reservations);

            B.AssociatedClinicians = Clinicians;
            B.Mother = AddMother();
            Random rand = new();

            if (rand.Next(1, 10) > 1)
            {
                B.Father = AddFather();
            }
            B.Relatives = AddRelatives();

            B.ChildrenToBeBorn = AddChildrenToBorn();
            B.IsEnded          = false;
            Context.Births.Add(B);
            Context.SaveChanges();
            return(true);
        }