コード例 #1
0
        public void createLocationCitizen(LocationCitizenService lcs, CitizenService cs, LocationService ls)
        {
            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 cit = cs.Get(ssn);
            var loc = ls.GetAddress(address);

            var LocationCitizenAdd = new LocationCitizen()
            {
                Address = address,
                SocialSecurityNumber = ssn,
                Date     = date,
                citizen  = cit,
                location = loc
            };

            lcs.Create(LocationCitizenAdd);

            Console.WriteLine("Location succesfully added!\n");
        }
コード例 #2
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(CitizenService cs, LocationService ls, LocationCitizenService lcs, int number = 100)
        {
            // Clears the database of LocationCitizen
            var myLocationCitizen = lcs.Get();

            foreach (var i in myLocationCitizen)
            {
                lcs.Remove(i);
            }

            for (int i = 0; i < number; i++)
            {
                //int rcit = random.Next(db.Citizen.Count());
                //int rloc = random.Next(db.Location.Count());

                int rcit = random.Next(100);
                int rloc = random.Next(100);

                var cit = cs.GetRandomCitizen(rcit);
                var loc = ls.GetRandomLocation(rloc);

                var lcc = new LocationCitizen()
                {
                    SocialSecurityNumber = cit.SocialSecurityNumber,
                    Address  = loc.Address,
                    Date     = $"{getDate()}{getMonth()}{getYear(0)}",
                    citizen  = cit,
                    location = loc
                };

                lcs.Create(lcc);
            }
        }