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"); }
// Genererer et antal tilfældige citizens, default 100. /// <summary> /// f**k en nice måde at lave kommentarer på tester123 /// </summary> /// <param name="db">DatabaseContext to add to</param> /// <param name="number">Amount of citizens to generate</param> public void GenerateCitizens(CitizenService cs, int number = 100) { // Clears the database of Citizens var myCitizen = cs.Get(); foreach (var i in myCitizen) { cs.Remove(i); } for (var i = 0; i < number; i++) { var age = random.Next(100); var temp = random.Next(Municipalities.Count); var cit = new Citizen() { FirstName = Firstnames[random.Next(Firstnames.Length)], LastName = Lastnames[random.Next(Lastnames.Length)], Sex = Genders[random.Next(Genders.Length)], Age = age, SocialSecurityNumber = $"{getDate()}{getMonth()}{getYear(age)}{getControl()}", MunicipalityID = Municipalities[temp] }; cs.Create(cit); } }
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"); }