コード例 #1
0
        public void ShowPotentialDonors(Patients patient, int numberOfDonors)
        {
            List <Donors> potentialDonors = patientsDAO.FindCompatibleDonors(patient);

            potentialDonors = potentialDonors.OrderBy(d => d.BloodGroup).Take(numberOfDonors).ToList();
            Console.WriteLine($"Here are all the donors compatible with your blood group {patient.BloodGroup} and their phone numbers.");
            for (int i = 0; i < potentialDonors.Count; i++)
            {
                Console.WriteLine($"{i + 1}. {potentialDonors[i].Name} {potentialDonors[i].PhoneNumber}");
            }
            Console.WriteLine();
            Console.Write("Pick the number of donor you want blood from: ");
            int donorIndex = 0;

            do
            {
                donorIndex = int.Parse(Console.ReadLine());
            } while (donorIndex <= 0 && donorIndex > numberOfDonors);
            Donors donatingDonor = potentialDonors[donorIndex - 1];

            donorsDAO.TransfuseBlood(donatingDonor, patient);
            Console.WriteLine($"You successfully received blood from {donatingDonor.Name}. You can call him to thank.");
            Console.WriteLine($"We hope your {patient.Diagnose} will be cured. Your account will be deleted now.");
            Console.WriteLine("If you receive blood again you can register at any time.");
            patientsDAO.DeletePatient(patient);
            Console.WriteLine("Press any key to return to the main menu.");
        }
コード例 #2
0
        public void PatientRegisterTest()
        {
            //Arrange
            PatientsDAO patientDAO = new PatientsDAO();

            HomeDAO homeDAO = new HomeDAO();
            Patient patient = new Patient
            {
                PatientId   = 90,
                Name        = "Test Patient 2",
                Email       = "*****@*****.**",
                Password    = "******",
                PhoneNumber = "0888123456",
                Diagnose    = "test",
                BloodGroup  = "B-"
            };

            //Act
            bool result = homeDAO.PatientRegister(patient);

            //Assert
            Assert.IsTrue(result);

            //Clean-Up
            patientDAO.DeletePatient(patient);
        }
コード例 #3
0
        public void DeletePatientTest()
        {
            //Arrange
            HomeDAO homeDAO = new HomeDAO();

            PatientsDAO patientsDAO = new PatientsDAO();
            Patient     testPatient = new Patient();

            testPatient.PatientId   = 102;
            testPatient.Name        = "Test Patient 2";
            testPatient.Email       = "*****@*****.**";
            testPatient.Password    = "******";
            testPatient.PhoneNumber = "0888123456";
            testPatient.Diagnose    = "test";
            testPatient.BloodGroup  = "A+";

            //Act
            homeDAO.PatientRegister(testPatient);
            patientsDAO.DeletePatient(testPatient);

            //Assert
            Assert.IsTrue(homeDAO.PatientLogin(testPatient.Email, testPatient.Password) == null);
        }
コード例 #4
0
 /// <summary>The patient receives the blood from the donor.</summary>
 /// <param name="patient">The patient.</param>
 /// <param name="donatingDonor">The donating donor.</param>
 public void ReceiveBlood(Patient patient, Donor donatingDonor)
 {
     donorsDAO.TransfuseBlood(donatingDonor, patient);
     patientsDAO.DeletePatient(patient);
 }