Пример #1
0
        // Udfylder LocationCitizen skyggetabellen, binder tilfældige citizens til tilfældige lokationer
        // Kræver at der allerede er Citizens og TestCenter i databasen
        public void AddCitizenToLocation(MyDBContext db, int number = 100)
        {
            for (int i = 0; i < number; i++)
            {
                int rcit = random.Next(db.Citizen.Count());
                int rloc = random.Next(db.Location.Count());

                var cit = db.Citizen.OrderBy(c => c.SocialSecurityNumber).Skip(i).Take(1).FirstOrDefault();
                var loc = db.Location.OrderBy(c => c.Address).Skip(i).Take(1).FirstOrDefault();

                var lcc = new LocationCitizen();
                lcc.SocialSecurityNumber = cit.SocialSecurityNumber;
                lcc.Address = loc.Address;

                lcc.date = $"{getDate()}{getMonth()}{getYear(0)}";

                db.Add(lcc);
                db.SaveChanges();
            }
        }
Пример #2
0
        public void createLocationCitizen(MyDBContext db)
        {
            Console.Clear();
            Console.WriteLine("Type in the address for the location: ");
            string address = Console.ReadLine();

            Console.WriteLine("Type in the SocialSecurityNumber for the citizen: ");
            string ssn = (Console.ReadLine());

            Console.WriteLine("Type in the date ");
            string date = (Console.ReadLine());

            var LocationCitizenAdd = new LocationCitizen()
            {
                Address = address, SocialSecurityNumber = ssn, date = date
            };

            db.Add(LocationCitizenAdd);
            db.SaveChanges();

            Console.WriteLine("Location succesfully added!\n");
        }