Пример #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 TransfuseBloodTest()
        {
            //Arrange
            HomeDAO homeDAO = new HomeDAO();

            DonorsDAO donorsDAO   = new DonorsDAO();
            Patient   testPatient = new Patient();

            testPatient.Name = "test";
            string email    = "*****@*****.**";
            string password = "******";

            //Act
            Donor donor = homeDAO.DonorLogin(email, password);

            donorsDAO.TransfuseBlood(donor, testPatient);

            //Assert
            Assert.AreEqual(testPatient.Name, donor.Status);
        }
Пример #3
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);
 }