Exemplo n.º 1
0
 //Method to get name of Care Giver through ID
 public string GetCareGiver(int id)
 {
     using (CareGivingDBEntities db = new CareGivingDBEntities())
     {
         //Finds row matching the given id and returns first and last name from that row
         var    rowData  = db.CareGiver.Find(id);
         string careName = rowData.FirstName + " " + rowData.LastName;
         return(careName);
     }
 }
Exemplo n.º 2
0
        public void AddCareGiver()
        {
            using (CareGivingDBEntities db = new CareGivingDBEntities())
            {
                Console.WriteLine("Please enter the last name of the new Care Giver below:");
                try
                {
                    lname = Console.ReadLine();
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }
                Console.WriteLine("Please enter the first name of the new Care Giver below:");
                try
                {
                    fname = Console.ReadLine();
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }
                Console.WriteLine("Please enter the role of the new Care Giver below (Orderly, Nurse etc.):");
                try
                {
                    role = Console.ReadLine();
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }
                Console.WriteLine("Please enter the unique ID of the workplace of the new Care Giver below:");
                try
                {
                    workplaceID = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }

                CareGiver newCareGiver = new CareGiver();
                newCareGiver.FirstName    = fname;
                newCareGiver.LastName     = lname;
                newCareGiver.Role         = role;
                newCareGiver.CareCenterId = workplaceID;

                db.CareGiver.Add(newCareGiver);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
 //Method to print all Care Takers
 public void ShowCareTaker()
 {
     using (CareGivingDBEntities db = new CareGivingDBEntities())
     {
         //Creates a list of Care Takers from the database
         var careTakerList = db.CareTaker.ToList();
         //Loops through the database tables and prints all relevant info
         foreach (var item in careTakerList)
         {
             Console.WriteLine("Last Name: " + item.LastName + " First Name: " + item.FirstName + "Liaison: " + fetchData.GetCareGiver(item.CareGiverId));
         }
     }
 }
Exemplo n.º 4
0
        public void AddCareTaker()
        {
            using (CareGivingDBEntities db = new CareGivingDBEntities())
            {
                Console.WriteLine("Please enter the last name of the new Care Taker below:");
                try
                {
                    lname = Console.ReadLine();
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }
                Console.WriteLine("Please enter the first name of the new Care Taker below:");
                try
                {
                    fname = Console.ReadLine();
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }
                Console.WriteLine("Please enter the unique ID of the liaison for the new Care Taker below:");
                try
                {
                    liaisonID = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Something went wrong");
                    throw;
                }

                CareTaker newCareTaker = new CareTaker();
                newCareTaker.FirstName   = fname;
                newCareTaker.LastName    = lname;
                newCareTaker.CareGiverId = liaisonID;

                db.CareTaker.Add(newCareTaker);
                db.SaveChanges();
            }
        }