示例#1
0
        public void TestCenterCreation(TestCenterService tcs)
        {
            Console.WriteLine("Enter ID for the testcenter: ");
            int TestCenterId = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter opening hours of the testcenter (fx. 8-16): ");
            string hours = Console.ReadLine();

            Console.WriteLine("Enter MunicipalityID for the municipality in which the testcenter is: ");
            int municipalityId = int.Parse(Console.ReadLine());

            var AddTestCenter = new TestCenter()
            {
                TestCenterId   = TestCenterId,
                OpenHours      = hours,
                MunicipalityId = municipalityId
            };

            tcs.Create(AddTestCenter);

            Console.WriteLine("TestCenter added!\n");
        }
示例#2
0
        public void ManagementCreation(TestCenterManagementService tcms, TestCenterService tcs)
        {
            Console.Clear();
            Console.WriteLine("Enter TestCenterManagements PhoneNumber:(8 digits): ");
            int phonenumber = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter TestCenterManagements Email address: ");
            string email = Console.ReadLine();

            Console.WriteLine("Enter TestCenterID by the managened TestCenter: ");
            int testcenterid = int.Parse(Console.ReadLine());

            var AddTestCenterManagement = new TestCenterManagement()
            {
                PhoneNumber  = phonenumber,
                Email        = email,
                TestCenterId = testcenterid,
                testcenter   = tcs.Get(testcenterid)
            };

            tcms.Create(AddTestCenterManagement);

            Console.WriteLine("TestCenterManagement added!\n");
        }
示例#3
0
        static void Main(string[] args)
        {
            DbClient client              = new DbClient(new MongoClient());
            var      citizenService      = new CitizenService(Client);
            var      municipalityService = new MunicipalityService(Client);
            var      locationService     = new LocationService(Client, municipalityService);
            var      testCenterService   = new TestCenterService(Client);
            var      testService         = new TestService(Client);

            bool run = true;

            while (run)
            {
                Console.WriteLine("[A] Add new Citizen");
                Console.WriteLine("[B] Add new TestCenter and TestCenterManagement");
                Console.WriteLine("[C] Add new Test");
                Console.WriteLine("[D] Add Test to all Citizens");
                Console.WriteLine("[E] Add new Location");
                Console.WriteLine("[F] Add Locations to all Citizens");
                Console.WriteLine("[G] Seed data");
                Console.WriteLine("[H] View active cases for Municipalities");
                Console.WriteLine("[I] View active cases by Sex");
                Console.WriteLine("[J] View active cases by Age");
                Console.WriteLine("[K] View possible cases by Location three days prior");
                Console.WriteLine("[X] Quit");
                Console.WriteLine("INPUT: ");

                var userInput = Console.ReadKey();

                switch (userInput.KeyChar)
                {
                case 'A':
                {
                    Console.Write("Firstname: ");
                    string firstname = Console.ReadLine();
                    Console.Write("Lastname: ");
                    string lastname = Console.ReadLine();
                    Console.Write("SSN (XXXXXX-XXXX): ");
                    string ssn = Console.ReadLine();
                    Console.Write("Age: ");
                    string age = Console.ReadLine();
                    Console.Write("Sex: ");
                    string sex = Console.ReadLine();
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();

                    int municipalityId = municipalityService.GetId(municipalityName);

                    var newCitizen = new Citizen
                    {
                        Firstname       = firstname,
                        Lastname        = lastname,
                        SSN             = ssn,
                        Age             = int.Parse(age),
                        Sex             = sex,
                        Tests           = new List <Test>(),
                        Location_id     = new List <int>(),
                        Municipality_id = municipalityId
                    };

                    citizenService.AddCitizen(newCitizen);
                }
                break;

                case 'B':
                {
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();
                    Console.Write("Hours: ");
                    int hours = int.Parse(Console.ReadLine());
                    Console.Write("Phonenumber: ");
                    int phonenumber = int.Parse(Console.ReadLine());
                    Console.Write("Email: ");
                    string email = Console.ReadLine();

                    testCenterService.AddTestCenter(municipalityName, hours, phonenumber, email);
                }
                break;

                case 'C':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("TestCenter-ID: ");
                    int testCenterId = int.Parse(Console.ReadLine());

                    if (Client.TestCenters.Find(t => t.TestCenterId == testCenterId).Any())
                    {
                        Console.WriteLine("No TestCenter with ID {0} exists.", testCenterId);
                        break;
                    }
                    else if (Client.Citizens.Find(c => c.CitizenId == citizenId).Any())
                    {
                        Console.WriteLine("No Citizen with ID {0} exists.", citizenId);
                        break;
                    }

                    testService.TestCitizen(citizenId, testCenterId);
                }
                break;

                case 'D':
                {
                    testService.TestAllCitizens();
                    Console.WriteLine("All citizens tested.");
                }
                break;

                case 'E':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("Address: ");
                    string address = Console.ReadLine();
                    Console.Write("Zip: ");
                    int zip = int.Parse(Console.ReadLine());
                    Console.Write("Municipality name: ");
                    string municipalityName = Console.ReadLine();

                    locationService.AddLocation(citizenId, address, zip, municipalityName);
                }
                break;

                case 'F':
                {
                    locationService.AddLocationToAllCitizen();
                    Console.WriteLine("All Citizen have now locations");
                }
                break;

                case 'G':
                {
                    Console.WriteLine("Sure you want to seed? Seeding will reset all Citizens and Municipalities[Y/N]");
                    string userKey = Console.ReadLine();

                    if (userKey.Contains('Y'))
                    {
                        Seed();
                        Console.WriteLine("Seeding done!");
                    }
                    else
                    {
                        Console.WriteLine("Seeding canceled.");
                    }
                }
                break;

                case 'H':
                {
                    testCenterService.ActiveCovidCasesPerMunicipality();
                }
                break;

                case 'I':
                {
                    testCenterService.ActiveCovidCasesSex();
                }
                break;

                case 'J':
                {
                    Console.Write("Min age: ");
                    int minAge = int.Parse(Console.ReadLine());
                    Console.Write("Max age: ");
                    int maxAge = int.Parse(Console.ReadLine());
                    int cases  = testCenterService.ActiveCovidCasesAge(minAge, maxAge);
                    Console.WriteLine("Total number of cases: {0}", cases);
                }
                break;

                case 'K':
                {
                    Console.Write("Infected citizen's ID: ");
                    int            citizenId = int.Parse(Console.ReadLine());
                    List <Citizen> citizens  = citizenService.CitizensAtSameLocation(citizenId);
                    Console.WriteLine("Citizens which has been the at the same location as an infected: ");
                    foreach (var citizen in citizens)
                    {
                        Console.WriteLine("-------------------------------------------------------");
                        Console.WriteLine($"ID: {citizen.CitizenId}");
                        Console.WriteLine($"Name: {citizen.Firstname} {citizen.Lastname}");
                        Console.WriteLine($"SSN : {citizen.SSN}");
                        Console.WriteLine("-------------------------------------------------------");
                    }
                }
                break;

                case 'X':
                    run = false;
                    break;
                }

                Console.WriteLine("\nPress any key.");
                Console.ReadKey();
                Console.Clear();
            }
        }
示例#4
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);
        }
示例#5
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");
        }