Beispiel #1
0
        ///<summary>
        /// Takes user input to create new patient object.
        ///</summary>
        public void createPatient()
        {
            PatientsModel patientToBe = new PatientsModel();

            Console.WriteLine("Enter Patient First name: ");
            patientToBe.fName = Console.ReadLine();
            Console.WriteLine("Enter Patient Last Name: ");
            patientToBe.lName = Console.ReadLine();
            Console.WriteLine("Enter Patient Age: ");
            int.TryParse(Console.ReadLine(), out int Age);
            patientToBe.age = Age;
            Console.WriteLine("Enter M or F for Gender: ");
            string gender = Console.ReadLine();

            patientToBe.Gender = gender[0];
            Console.WriteLine("Enter Admit Date: (MM/DD/YYYY)");
            patientToBe.AdmitDate = DateTime.Parse(Console.ReadLine());
            Console.WriteLine("Has Patient had an Exam with the doctor? y/n");
            string exam = Console.ReadLine();

            exam = exam.ToUpper();
            if (exam[0] == 'Y')
            {
                patientToBe.HadExam = true;
            }
            else
            {
                patientToBe.HadExam = false;
            }
            //thought it'd be good practice to see the newly create patient object before saving it
            //although there's no functionality to go back and edit it
            Console.WriteLine($"Here is the patient you've created: \n{patientToBe.fName} {patientToBe.lName} \nAge: {patientToBe.age} \nGender: {patientToBe.Gender} \nAdmitted:{patientToBe.AdmitDate.ToString()}\n Seen Doctor? {patientToBe.HadExam}");
            Console.WriteLine("Would you like to save it?");
            string resp = Console.ReadLine();

            resp = resp.ToUpper();
            if (resp[0] == 'Y')
            {
                crud db = new crud();
                db.CreatePatient(patientToBe);
            }
        }
Beispiel #2
0
 // CREATE:
 ///<summary>
 /// Takes whole PatientsModel object and adds it to the database.
 ///</summary>
 public void CreatePatient(PatientsModel patient)
 {
     DB.Add(patient);
     DB.SaveChanges();
 }