コード例 #1
0
        private void AddNewAppointment()
        {
            Console.WriteLine("Creating a new Appointment");

            Console.WriteLine("Existing Client? (Y or N)");

            string answer = Console.ReadLine().ToLower();

            if (answer == "y")
            {
                Appointment appointment = new Appointment();

                Console.WriteLine("Enter Client's ID:");
                int    clientId = int.Parse(Console.ReadLine());
                Client i        = FindClient(clientId);
                appointment.ClientId = i.ClientId;
                Console.WriteLine("***********************");
                Console.WriteLine($"Info about the Client:\n{i.ShowShortInfo()}");

                Console.WriteLine("***********************");
                Console.WriteLine("List of lawyers with the matching expertise:");

                //searching for the matching experitise
                var foundLawyerslist = lawyers.FindAll(x => x.Expertise == i.CaseType);

                foreach (Lawyer lawyer in foundLawyerslist)
                {
                    Console.WriteLine(lawyer.ShowInfo());
                }

                Console.WriteLine("Assign the lawyer by typing Laywer's last name:");
                string lawyerAssigned = Console.ReadLine().ToLower();


                Lawyer l = lawyers.Find(x => x.Lastname.ToLower() == lawyerAssigned);
                appointment.LawyerId = l.EmpId;


                Console.WriteLine("Appointment ID:");
                appointment.AppId = int.Parse(Console.ReadLine());

                Console.WriteLine("Appointment's date (dd-MM-yyyy):");
                appointment.AppointmentDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", null);
                Console.WriteLine("Appointment's time (HH:mm):");
                appointment.AppointmentDate = DateTime.ParseExact(Console.ReadLine(), "HH:mm", null);


                Console.WriteLine("Choose room:");
                Console.WriteLine("1. Aquarium\n2. Cave\n3. Cube");
                int roomChoice = int.Parse(Console.ReadLine());
                if (roomChoice == 1)
                {
                    appointment.MeetingRoom = ERooms.Aquarium;
                }
                else if (roomChoice == 2)
                {
                    appointment.MeetingRoom = ERooms.Cave;
                }
                else if (roomChoice == 3)
                {
                    appointment.MeetingRoom = ERooms.Cube;
                }
                else
                {
                    appointment.MeetingRoom = ERooms.Unknown;
                }

                appointments.Add(appointment);

                Console.WriteLine("New appointment is created:");
                Console.WriteLine($"Client: {i.Firstname} {i.Lastname} from {i.City} (case: {i.CaseType} law)");
                Console.WriteLine($"Lawyer assigned: {l.Firstname} {l.Lastname} specialised in {l.Expertise} law and with seniority as {l.Seniority}");
                Console.WriteLine($"Date of appointment: {appointment.AppointmentDate.ToShortDateString()}");
                Console.WriteLine($"Time of appointment: {appointment.AppointmentTime.ToShortTimeString()}");
                Console.WriteLine("******************************");
            }

            else
            {
                AddNewClient();
            }
        }
コード例 #2
0
        private void AddNewCase()
        {
            Console.WriteLine("Creating a new Case");

            Console.WriteLine("Enter Lawyer ID:");

            // collecting answer from user and validation of input as integer
            int  idInput;
            bool valid; //false by default

            do
            {
                valid = int.TryParse(Console.ReadLine(), out idInput);
            }while (!valid);

            //creating object lawyer with the requested id via search method
            Lawyer lawyer = FindLawyer(idInput);

            if (lawyer != null)
            {
                Clientcase clientcase = new Clientcase();

                clientcase.LawyerId = lawyer.EmpId;

                lawyer.GreetEmployee();

                Console.WriteLine("Enter Client's ID:");

                int  clientId;
                bool valid1; //false by default
                do
                {
                    valid1 = int.TryParse(Console.ReadLine(), out clientId);
                }while (!valid1);

                Client client = FindClient(clientId);

                clientcase.ClientId = client.ClientId;

                Console.WriteLine("***********************");
                Console.WriteLine($"Info about the Client:\n{client.ShowShortInfo()}");

                if (client.CaseType != lawyer.Expertise)
                {
                    Console.WriteLine($"Hello, {lawyer.Firstname} are you sure you have enough expertise for this? Better ask your collegue");
                }

                else
                {
                    Console.WriteLine("Assigning Id Case:");
                    clientcase.IdCase   = int.Parse(Console.ReadLine());
                    clientcase.CaseType = client.CaseType;

                    clientcase.StartDate = DateTime.Now; //assigning start date of the case to the current date

                    Console.WriteLine("Enter the total charge of Client:");
                    clientcase.TotalCharges = int.Parse(Console.ReadLine());

                    cases.Add(clientcase);

                    Console.WriteLine("New Case created:");
                    Console.WriteLine($"{clientcase.ShowInfo()}\nClient:\n{client.ShowShortInfo()}");
                }
            }

            else
            {
                Console.WriteLine("The ID does not exist");
                Console.WriteLine("Please start creating the Case from beginning");
                AddNewCase();
            }
        }