public void setPractice(string location)
 {
     if (DataSearching.practiceExists(location))
     {
         practice = DataSearching.findPractice(location);
     }
 }
        /**
         * Shows the staff manager allowing admins to assign staff to locations.
         */
        private void showStaffMgr()
        {
            string response;
            bool   inMenu;

            try
            {
                inMenu = true;
                do
                {
                    DataPrinting.printPractices(); //Find practices and show them
                    Console.Write("Location to manage: (enter empty location to exit)");
                    response = Console.ReadLine();
                    Console.Clear();

                    if (response == "")
                    {
                        inMenu = false;
                    }
                    else if (DataSearching.practiceExists(response))          //Checks if practice exsists with given practice
                    {
                        managePractice(DataSearching.findPractice(response)); //finds practice based on given response
                    }
                    else
                    {
                        Console.WriteLine("Location does not exist.");
                    }
                }while (inMenu);
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /**
         * Removes a practice.
         */
        private void removePractice()
        {
            List <DentalPractice> practices = Application.appInstance.dentalPractices;
            List <TreatmentRoom>  associatedRooms;
            string         response = "";
            DentalPractice practiceToRemove;
            bool           inMenu = true;

            try
            {
                do
                {
                    Console.Write("Practice to remove (leave blank to cancel): ");
                    response = Console.ReadLine();
                    Console.Clear();

                    inMenu = (response != "");

                    if (inMenu)
                    {
                        if (practices.Exists(practice => practice.getLocation() == response)) //Checks to see the given practice exists.
                        {
                            practiceToRemove = DataSearching.findPractice(response);          //Finds practice based on response
                            associatedRooms  = practiceToRemove.getRooms();

                            for (int i = 0; i < associatedRooms.Count; i++) //Iterates over every room
                            {
                                deleteRoom(associatedRooms[i], false);      //Deletes all rooms
                            }

                            practices.Remove(practiceToRemove); //Removes pratice from the list
                        }
                        else
                        {
                            Console.WriteLine("Practice not found.");
                        }
                    }
                }while (inMenu);
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /**
         * Shows the room editor.
         */
        private void showRoomEditor()
        {
            bool           inMenu;
            string         response = "";
            DentalPractice practiceToAddRoom;

            try
            {
                inMenu = true;

                while (inMenu)
                {
                    DataPrinting.printPractices();
                    Console.WriteLine("Practice to add room to: (Leave blank to cancel)");
                    response = Console.ReadLine();
                    Console.Clear();

                    if (response != "")
                    {
                        if (DataSearching.practiceExists(response))                   //uses response to find the practices that are a valid response
                        {
                            practiceToAddRoom = DataSearching.findPractice(response); // takes response and gets pratice with the given response and location
                            addRoomToPractice(practiceToAddRoom);                     //run method to add practice
                        }
                        else
                        {
                            Console.WriteLine("Practice does not exist.");
                        }
                    }
                    else
                    {
                        inMenu = false;
                    }
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
 public Staff(string username, string password, string name, string location): base(username, password, name) //calls the constructor of the parent class, inheritance. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/base
 {
     practice = DataSearching.findPractice(location);
 }
        /**
         * Adds a user to the system.
         */
        private void addUser()
        {
            string         username;
            string         password;
            string         name;
            int            role;
            string         location = "";
            User           userToAdd;
            List <User>    users = Application.appInstance.users;
            DentalPractice practice;

            try
            {
                //Input to create user
                username = GeneralFunctions.getRequiredInput("Username: "******"Password: "******"Name: ");
                role     = GeneralFunctions.getRequiredSelection("Role: ", new string[] { "Administrator", "Receptionist", "Dentist", "Nurse" }); //Passes a string to label the input and a string array of available options.

                if (role != 1)                                                                                                                    // if not administrator.
                {
                    location = getValidLocation();
                }

                switch (role)
                {
                case 1:
                    userToAdd = new Administrator(username, password, name);
                    users.Add(userToAdd);       //Adds to the Users
                    DataIO.saveUser(userToAdd); //Saves to files
                    break;

                case 2:
                    userToAdd = new Receptionist(username, password, name, location);
                    users.Add(userToAdd);
                    DataIO.saveUser(userToAdd);

                    if (location != "")
                    {
                        practice = DataSearching.findPractice(location);     //Uses location string to find practice
                        practice.setReceptionist((Receptionist)userToAdd);   //Sets the receptionist at the practice to the new user.
                    }
                    break;

                case 3:
                    userToAdd = new DentistNurse(username, password, name, location, "Dentist");     //Creates a new user and sets practioner type to Dentist
                    users.Add(userToAdd);
                    DataIO.saveUser(userToAdd);
                    break;

                case 4:
                    userToAdd = new DentistNurse(username, password, name, location, "Nurse");     //Creates a new user and sets practioner type to Nurse
                    users.Add(userToAdd);
                    DataIO.saveUser(userToAdd);
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /**
         * Provides an interface allowing admin to Remove a room.
         */
        private void removeRoom()
        {
            string         response;
            int            responseInt;
            bool           inMenu;
            bool           invalidResponse;
            DentalPractice practiceToRemoveFrom;
            TreatmentRoom  roomToRemove;

            try
            {
                inMenu = true;

                while (inMenu)
                {
                    DataPrinting.printPractices();
                    Console.Write("Practice to remove room from: (leave blank to cancel)");
                    response = Console.ReadLine();
                    Console.Clear();

                    if (response != "")
                    {
                        if (DataSearching.practiceExists(response))                      //Checks for valid user response
                        {
                            practiceToRemoveFrom = DataSearching.findPractice(response); //Gets practice with given ID
                            invalidResponse      = true;

                            while (inMenu && invalidResponse)
                            {
                                DataPrinting.printRoomsAtPractice(practiceToRemoveFrom); //Shows all rooms in the given practice
                                Console.Write("Select room to remove: (leave blank to cancel)");
                                response = Console.ReadLine();
                                Console.Clear();

                                if (response != "")
                                {
                                    if (int.TryParse(response, out responseInt))                                     //Converts value to int as responseInt
                                    {
                                        if (responseInt > 0 && responseInt <= practiceToRemoveFrom.getRooms().Count) //Checking if response is greater than 0 or less than or equal the given amount of rooms.
                                        {
                                            roomToRemove = practiceToRemoveFrom.getRooms()[responseInt - 1];
                                            deleteRoom(roomToRemove, true); //Removes the room
                                        }
                                        else
                                        {
                                            Console.WriteLine("Invalid room");
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("Enter a number.");
                                    }
                                }
                                else
                                {
                                    invalidResponse = false;//Breaks loop
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Practice not found.");
                        }
                    }
                    else
                    {
                        inMenu = false;
                    }
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /**
         * Shows the room managing interface.
         */
        private void showRoomMgr()
        {
            string response;
            int    responseInt;
            bool   inMenu;

            DentalPractice       practice;
            List <TreatmentRoom> rooms;

            try
            {
                inMenu = true;
                bool invalidPractice;
                bool invalidRoom;

                while (inMenu)
                {
                    invalidPractice = true;
                    while (invalidPractice && inMenu)  //Selecting a location and room.
                    {
                        DataPrinting.printPractices(); //Show practices
                        Console.Write("Practice: (leave blank to cancel)");
                        response = Console.ReadLine();
                        Console.Clear();

                        if (response == "")
                        {
                            inMenu = false;                              //if blank, allows loop to break.
                        }
                        else if (DataSearching.practiceExists(response)) //Checks if it is a valid response
                        {
                            invalidPractice = false;
                            invalidRoom     = true;

                            practice = DataSearching.findPractice(response); //Gets practice with given ID
                            rooms    = practice.getRooms();                  //Gets list of rooms

                            while (invalidRoom && inMenu)                    //Selecting a room
                            {
                                DataPrinting.printRoomsAtPractice(practice); //Prints rooms based on practice location
                                Console.WriteLine("Room to manage: (leave blank to cancel)");
                                response = Console.ReadLine();

                                if (response == "")
                                {
                                    invalidRoom = false;
                                }
                                if (int.TryParse(response, out responseInt))
                                {
                                    if (responseInt > 0 && responseInt <= rooms.Count)
                                    {
                                        manageRoom(rooms[responseInt - 1]); //Brings up interface for managing a room. indexing rooms list -1.
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Location not found");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }