예제 #1
0
        // Udfylder skyggetabellen TestCenterCitizen, binder tilfældige citizens til tilfældige testcentre
        // Kræver at der allerede er Citizens og TestCenter i databasen
        public void AddCitizenToTestCenter(CitizenService cs, TestCenterService tcs, TestCenterCitizenService tccs, int number = 100)
        {
            // Clears the database of TestCenterCitizens
            var myTestCenterCitizen = tccs.Get();

            foreach (var i in myTestCenterCitizen)
            {
                tccs.Remove(i);
            }

            for (int i = 0; i < number; i++)
            {
                //int rcit = random.Next((int)cs.GetCount());
                //int rtcr = random.Next((int)tcs.GetCount());

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

                var cit = cs.GetRandomCitizen(rcit);
                var tcr = tcs.GetRandomTestCenter(rtcr);

                var tcc = new TestCenterCitizen()
                {
                    SocialSecurityNumber = cit.SocialSecurityNumber,
                    TestCenterID         = tcr.TestCenterID,
                    date       = $"{getDate()}{getMonth()}{getYear(0)}",
                    citizen    = cit,
                    testCenter = tcr
                };

                int rnum = random.Next(100);
                if (rnum < 33)
                {
                    tcc.result = false;
                    tcc.status = "Not Ready";
                }
                else if (rnum < 66)
                {
                    tcc.result = true;
                    tcc.status = "Ready";
                }
                else if (rnum <= 100)
                {
                    tcc.result = false;
                    tcc.status = "Ready";
                }

                tccs.Create(tcc);
            }
        }
예제 #2
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");
        }
예제 #3
0
 public void Update(string socialSecurityNumber, TestCenterCitizen testCenterCitizenIn) =>
 _testcentercitizens.ReplaceOne(testcentercitizen => testcentercitizen.SocialSecurityNumber == socialSecurityNumber, testCenterCitizenIn);
예제 #4
0
 public void Remove(TestCenterCitizen testCenterCitizenIn) =>
 _testcentercitizens.DeleteOne(testcentercitizen => testcentercitizen.SocialSecurityNumber == testCenterCitizenIn.SocialSecurityNumber);
예제 #5
0
 //Create, Update, Remove
 public TestCenterCitizen Create(TestCenterCitizen testCenterCitizen)
 {
     _testcentercitizens.InsertOne(testCenterCitizen);
     return(testCenterCitizen);
 }