Ejemplo n.º 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(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);
            }
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
0
        public void LocationCitizenCreation(LocationCitizenService lcs, CitizenService cs, LocationService ls)
        {
            Console.Clear();
            Console.WriteLine("Enter address for the location: ");
            string address = Console.ReadLine();

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

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

            var cit = cs.Get(ssn);
            var loc = ls.GetAddress(address);

            var addLocationCitizen = new LocationCitizen()
            {
                Address  = address,
                SSN      = ssn,
                date     = date,
                citizen  = cit,
                location = loc
            };

            lcs.Create(addLocationCitizen);

            Console.WriteLine("Location added!\n");
        }
Ejemplo n.º 4
0
        public void createTestCase(CitizenService cs, TestCenterService tcs, TestCenterCitizenService tccs, LocationCitizenService lcs)
        {
            Console.Clear();
            Console.WriteLine("Type the SocialSecurityNumber of the citizen: ");
            string temp1 = Console.ReadLine();
            string ssn   = temp1.Trim();

            Console.Clear();
            Console.WriteLine("Type the TestCenterID of the TestCenter where the test was made: ");
            string temp2        = Console.ReadLine();
            int    testcenterid = int.Parse(temp2);

            var cit = cs.Get(ssn);
            var tcr = tcs.Get(testcenterid);

            var tcc = new TestCenterCitizen();

            tcc.SocialSecurityNumber = cit.SocialSecurityNumber;
            tcc.TestCenterID         = tcr.TestCenterID;
            tcc.citizen    = cit;
            tcc.testCenter = tcr;

            Console.Clear();
            Console.WriteLine("Type the date of the test (ddmmyy): ");
            string date12 = Console.ReadLine();

            tcc.date = date12;

            Console.Clear();
            Console.WriteLine("Type the status of the test (Not Tested, Not Ready, Ready): ");
            string status = Console.ReadLine();

            tcc.status = status;

            Console.Clear();
            Console.WriteLine("Type the test result: \n" +
                              "'P' for positive\n" +
                              "'N' for negative/unknown\n");
            string temp  = Console.ReadLine();
            int    check = 0;

            do
            {
                if (temp == "P")
                {
                    tcc.result = true;
                    check      = 1;

                    //using (var context = new MyDBContext())
                    //{
                    var tmpresult = lcs.GetSSN(ssn);

                    foreach (LocationCitizen loccit in tmpresult)
                    {
                        var adress = loccit.Address;
                        var tmp2   = lcs.GetADR(adress);

                        // Får den nuværende dato
                        DateTime dt      = DateTime.Now;
                        DateTime dt3days = dt.AddDays(-3);

                        // Får den smittede persons dato
                        string   day1     = loccit.Date.Substring(0, 2);
                        string   month1   = loccit.Date.Substring(2, 2);
                        string   year1    = "20" + loccit.Date.Substring(4, 2);
                        DateTime infectdt = new DateTime(int.Parse(year1), int.Parse(month1), int.Parse(day1));

                        float compareStart = infectdt.CompareTo(dt3days);
                        Console.WriteLine(dt);
                        Console.WriteLine(infectdt);
                        if (compareStart <= 0)
                        {
                            DateTime dt1;
                            DateTime dt2;
                            DateTime dt3;
                            // Trækker 3 dage fra for at se om den er aktiv
                            dt1 = dt.AddDays(-1);
                            dt2 = dt.AddDays(-2);
                            dt3 = dt.AddDays(-3);
                            // Fjerner timer/minutter/sekunder fra DateTime
                            string stringdt1 = dt1.ToShortDateString();
                            dt1 = Convert.ToDateTime(stringdt1);
                            string stringdt2 = dt2.ToShortDateString();
                            dt2 = Convert.ToDateTime(stringdt2);
                            string stringdt3 = dt3.ToShortDateString();
                            dt3 = Convert.ToDateTime(stringdt3);

                            var table = new ConsoleTable("People who MIGHT be infected");

                            foreach (LocationCitizen C in tmp2)
                            {
                                // Formaterer Citizen dato til DateTime og sammenligner med dt1/2/3
                                string   day      = C.Date.Substring(0, 2);
                                string   month    = C.Date.Substring(2, 2);
                                string   year     = "20" + C.Date.Substring(4, 2);
                                DateTime citdt    = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day));
                                float    compare1 = dt1.CompareTo(citdt);
                                float    compare2 = dt2.CompareTo(citdt);
                                float    compare3 = dt3.CompareTo(citdt);

                                if (compare1 == 0 || compare2 == 0 || compare3 == 0)
                                {
                                    if (C.SocialSecurityNumber != ssn)
                                    {
                                        table.AddRow(C.SocialSecurityNumber);
                                    }
                                }
                            }
                            table.Write();
                            Console.WriteLine("Press any key to end");
                            Console.ReadLine();
                        }
                    }
                    //}
                }
                else if (temp == "N")
                {
                    tcc.result = false;
                    check      = 1;
                }
                else
                {
                    Console.WriteLine("Please type a valid result: ");
                    temp  = Console.ReadLine();
                    check = 0;
                }
            } while (check == 0);

            tccs.Create(tcc);

            Console.WriteLine("Test Case succesfully added!\n");
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            CitizenService              cs   = new CitizenService();
            LocationService             ls   = new LocationService();
            MunicipalityService         ms   = new MunicipalityService();
            CountryService              ns   = new CountryService();
            TestCenterService           tcs  = new TestCenterService();
            TestCenterManagementService tcms = new TestCenterManagementService();

            LocationCitizenService   lcs  = new LocationCitizenService();
            TestCenterCitizenService tccs = new TestCenterCitizenService();

            MongoFunctions cf = new MongoFunctions();

            int  choice;
            bool done = false;

            do
            {
                Console.WriteLine("Time to choose \n"
                                  + " 1: to add a new citizen\n"
                                  + " 2: to add Testcenter\n"
                                  + " 3: to add Management\n"
                                  + " 4: to add Testcase\n"
                                  + " 5: to a add location\n"
                                  + " 6: to add Location Citizen\n"
                                  + " 0: to exit");

                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    cf.citizenCreation(cs);
                    break;

                case 2:
                    cf.TestCenterCreation(tcs);
                    break;

                case 3:
                    cf.ManagementCreation(tcms, tcs);
                    break;

                case 4:
                    cf.TestCaseCreation(cs, tcs, tccs, lcs);
                    break;

                case 5:
                    cf.LocationCreation(ls);
                    break;

                case 6:
                    cf.LocationCitizenCreation(lcs, cs, ls);
                    break;


                case 0:
                    done = true;
                    break;
                }
            } while (true);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            CitizenService              cs   = new CitizenService();
            LocationService             ls   = new LocationService();
            MunicipalityService         ms   = new MunicipalityService();
            NationService               ns   = new NationService();
            TestCenterService           tcs  = new TestCenterService();
            TestCenterManagementService tcms = new TestCenterManagementService();

            LocationCitizenService   lcs  = new LocationCitizenService();
            TestCenterCitizenService tccs = new TestCenterCitizenService();

            GenerateFunctions gf = new GenerateFunctions();
            CreateFunctions   cf = new CreateFunctions();

            int  choice;
            int  choice2;
            bool finished       = false;
            bool finishedSearch = false;


            // program start
            Console.WriteLine("Make a choice! \n" +
                              " 1: Add Denmark municipality and random dummy data\n" +
                              " 2: Empty database");
            choice = Convert.ToInt32(Console.ReadLine());
            switch (choice)
            {
            case 1:
                Console.Clear();
                gf.ParseMunicipality(ms, ns);
                gf.GenerateTestCenter(tcs, 100);
                gf.GenerateCitizens(cs, 100);
                gf.AddCitizenToTestCenter(cs, tcs, tccs);
                gf.GenerateLocation(ls, 100);
                gf.AddCitizenToLocation(cs, ls, lcs, 100);
                gf.GenerateTestCenterManagement(tcms, tcs, 100);
                break;

            case 2:
                Console.Clear();
                break;
            }

            choice = 0;
            do
            {
                Console.Clear();
                Console.WriteLine("Choose an option... \n" +
                                  " 1: Create Citizen\n" +
                                  " 2: Create Test Center\n" +
                                  " 3: Create Management\n" +
                                  " 4: Create Test Case\n" +
                                  " 5: Create Location\n" +
                                  " 6: Create LocationCitizen\n" +
                                  " 7: Search the database\n" +
                                  " 0: Exit");

                choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    cf.createCitizen(cs);
                    break;

                case 2:
                    cf.createTestCenter(tcs);
                    break;

                case 3:
                    cf.createManagement(tcms, tcs);
                    break;

                case 4:
                    cf.createTestCase(cs, tcs, tccs, lcs);
                    break;

                case 5:
                    cf.createLocation(ls);
                    break;

                case 6:
                    cf.createLocationCitizen(lcs, cs, ls);
                    break;

                case 7:
                    Console.Clear();
                    do
                    {
                        Console.Clear();
                        Console.WriteLine("What do you want to search by? \n" +
                                          " 1: Search by name\n" +
                                          " 2: Search by age groups\n" +
                                          " 3: Search by gender\n" +
                                          " 4: Search by municipality\n" +
                                          " 0: Exit search");

                        choice2 = Convert.ToInt32(Console.ReadLine());
                        switch (choice2)
                        {
                        case 1:
                            cf.searchForCitizen(cs);
                            break;

                        case 2:
                            cf.searchforAge(tccs);
                            break;

                        case 3:
                            cf.searchforSex(tccs);
                            break;

                        case 4:
                            cf.SearchForMunincipality(tccs);
                            break;

                        case 0:
                            finishedSearch = true;
                            break;
                        }
                    } while (finishedSearch == false);
                    break;

                case 0:
                    finished = true;
                    break;
                }
            } while (finished == false);
        }
Ejemplo n.º 7
0
        public void TestCaseCreation(CitizenService cs, TestCenterService tcs, TestCenterCitizenService tccs, LocationCitizenService lcs)
        {
            Console.Clear();
            Console.WriteLine("Enter Social sericurity number for a citizen: ");
            string tempSSN = Console.ReadLine();
            string ssn     = tempSSN.Trim();

            Console.Clear();
            Console.WriteLine("Enter TestCenterId for where the testcenter occured: ");
            string tempTest = Console.ReadLine();
            int    tcid     = int.Parse(tempTest);

            var cit = cs.Get(ssn);
            var tcr = tcs.Get(tcid);

            var tcc = new TestCenterCitizen();

            tcc.SSN          = cit.SSN;
            tcc.TestCenterId = tcr.TestCenterId;
            tcc.citizen      = cit;
            tcc.testCenter   = tcr;

            Console.Clear();
            Console.WriteLine("Enter date for the test in the format (ddmmyy): ");
            string tempDate = Console.ReadLine();

            tcc.Date = tempDate;

            Console.Clear();
            Console.WriteLine("Enter status for the test either ready, done or not done: ");
            string statusOfTest = Console.ReadLine();

            tcc.Status = statusOfTest;

            Console.Clear();
            Console.WriteLine("Enter test result, P = Positve and N = Negative\n");
            string tempResult = Console.ReadLine();
            int    checkBool  = 0;

            do
            {
                if (tempResult == "P")
                {
                    tcc.Result = true;
                    checkBool  = 1;
                }
                else if (tempResult == "N")
                {
                    tcc.Result = false;
                    checkBool  = 1;
                }
                else
                {
                    Console.WriteLine("Enter valid result: ");
                    tempResult = Console.ReadLine();
                    checkBool  = 0;
                }
            } while (checkBool == 0);

            tccs.Create(tcc);
            Console.WriteLine("Test case added\n");
        }