Exemple #1
0
        public void searchforSex(TestCenterCitizenService tccs)
        {
            List <TestCenterCitizen> _tempresult = new List <TestCenterCitizen>();
            {
                Console.WriteLine("Type the gender you want to search by (male/female): ");
                string sex = Console.ReadLine();

                switch (sex)
                {
                case "male":
                    Console.WriteLine("Positive cases for men");
                    var tempsex = tccs.Get()
                                  .Where(c => c.citizen.Sex == "male" || c.citizen.Sex == "Male")
                                  .ToList();
                    _tempresult = tempsex;
                    break;

                case "Male":
                    Console.WriteLine("Positive cases for men");
                    tempsex = tccs.Get()
                              .Where(c => c.citizen.Sex == "male" || c.citizen.Sex == "Male")
                              .ToList();
                    _tempresult = tempsex;
                    break;

                case "female":
                    Console.WriteLine("Positive cases for women");
                    tempsex = tccs.Get()
                              .Where(c => c.citizen.Sex == "female" || c.citizen.Sex == "Female")
                              .ToList();
                    _tempresult = tempsex;
                    break;

                case "Female":
                    Console.WriteLine("Positive cases for women");
                    tempsex = tccs.Get()
                              .Where(c => c.citizen.Sex == "female" || c.citizen.Sex == "Female")
                              .ToList();
                    _tempresult = tempsex;
                    break;
                }

                var table         = new ConsoleTable("Positive cases");
                int PositiveCases = 0;

                foreach (TestCenterCitizen C in _tempresult)
                {
                    if (C.result == true)
                    {
                        PositiveCases++;
                    }
                }

                table.AddRow(PositiveCases);
                table.Write();
                Console.WriteLine("Press any key to end");
                Console.ReadLine();
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        public void SearchForMunincipality(TestCenterCitizenService tccs)
        {
            List <TestCenterCitizen> _tmpresult = new List <TestCenterCitizen>();
            {
                Console.WriteLine("Type the municipalityId you want to see: ");
                int mid = int.Parse(Console.ReadLine());

                Console.WriteLine($"Positive cases for munincipality {mid}");
                var tempres = tccs.Get()
                              .Where(tcc => tcc.citizen.MunicipalityID == mid).ToList();

                _tmpresult = tempres;

                var table         = new ConsoleTable("Active positive cases");
                int PositiveCases = 0;

                // Får den nuværende dato
                DateTime dt = DateTime.Now;
                // Trækker 14 dage fra for at se om den er aktiv
                dt = dt.AddDays(-14);
                // Laver det om til en string, formarterer det osv.
                string date = dt.ToShortDateString();
                date = date.Replace("-", "");
                string date1 = date.Substring(0, 4);
                string date2 = date.Substring(6, 2);
                date = date1 + date2;

                foreach (TestCenterCitizen C in _tmpresult)
                {
                    // Formaterer Citizen test casens dato til DateTime og sammenligner med dt
                    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    compare = dt.CompareTo(citdt);

                    if (C.result == true && compare <= 0)
                    {
                        PositiveCases++;
                    }
                }

                table.AddRow(PositiveCases);
                table.Write();
                Console.WriteLine("Press any key to end");
                Console.ReadLine();
            }
        }
Exemple #4
0
        public void searchforAge(TestCenterCitizenService tccs)
        {
            //using (var context = new MyDBContext())
            //{
            Console.WriteLine("Choose an age group to show amount of positive cases \n" +
                              " 1: 0-10\n" +
                              " 2: 11-20\n" +
                              " 3: 21-30\n" +
                              " 4: 31-40\n" +
                              " 5: 41-50\n" +
                              " 6: 51-60\n" +
                              " 7: 61-70\n" +
                              " 8: 71-80\n" +
                              " 9: 81-90\n" +
                              " 0: 91-100\n" +
                              " 99: Exit");

            int tempInput = int.Parse(Console.ReadLine());

            List <TestCenterCitizen> tempresult_ = new List <TestCenterCitizen>();

            switch (tempInput)
            {
            case 1:
                Console.WriteLine("Positive cases for age group 0-10");
                var tempresult = tccs.Get()
                                 .Where(x => x.citizen.Age >= 0 && x.citizen.Age <= 10)
                                 .ToList();
                tempresult_ = tempresult;
                break;

            case 2:
                Console.WriteLine("Positive cases for age group 11-20");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 11 && x.citizen.Age <= 20)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 3:
                Console.WriteLine("Positive cases for age group 21-30");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 21 && x.citizen.Age <= 30)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 4:
                Console.WriteLine("Positive cases for age group 31-40");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 31 && x.citizen.Age <= 40)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 5:
                Console.WriteLine("Positive cases for age group 41-50");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 41 && x.citizen.Age <= 50)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 6:
                Console.WriteLine("Positive cases for age group 51-60");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 51 && x.citizen.Age <= 60)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 7:
                Console.WriteLine("Positive cases for age group 61-70");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 61 && x.citizen.Age <= 70)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 8:
                Console.WriteLine("Positive cases for age group 71-80");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 71 && x.citizen.Age <= 80)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 9:
                Console.WriteLine("Positive cases for age group 81-90");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 81 && x.citizen.Age <= 90)
                             .ToList();
                tempresult_ = tempresult;
                break;

            case 0:
                Console.WriteLine("Positive cases for age group 91-100");
                tempresult = tccs.Get()
                             .Where(x => x.citizen.Age >= 91 && x.citizen.Age <= 100)
                             .ToList();
                tempresult_ = tempresult;
                break;
            }

            var table         = new ConsoleTable("Positive cases");
            int PositiveCases = 0;


            foreach (TestCenterCitizen C in tempresult_)
            {
                if (C.result == true)
                {
                    PositiveCases++;
                }
            }

            table.AddRow(PositiveCases);

            table.Write();
            Console.WriteLine("Press any key to end");
            Console.ReadLine();
            //}
        }
Exemple #5
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");
        }
Exemple #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);
        }