Пример #1
0
        private static void AddContract(BL_imp bl)
        {
            Console.Clear();
            Console.WriteLine("Welcome To Contract Creater Wizard!\n");
            Console.WriteLine("Below is a list of the nannyless children. Please enter the number representing the child you'd like to create a contract for:\n");
            var nannyless_children = bl.get_all_nannyless_kids();
            int counter = 0, selected_child, selected_nanny;

            foreach (Child c in nannyless_children)
            {
                Console.WriteLine("{0}.\t{1}", ++counter, c.ToString());
            }
            Console.Write("\nI choose child num: ");
            selected_child = int.Parse(Console.ReadLine());

            var child = nannyless_children[selected_child - 1];
            var mother = bl.get_mother(child);

            var available_nannies = bl.check_secondry_match(mother);                    //will return initiall match if exists

            //perfect matches are avalable
            bool perfect_matches = false;

            if (bl.check_initial_match(mother).Count > 0)
            {
                Console.WriteLine("\nBelow is a table with nannys available on the hours " + child.First_Name + " needs.\n" +
                                  "Please enter the number representing the nanny you'd like to set up with " + child.First_Name + ":\n");
                perfect_matches = true;
            }

            //no perfect matches are avalable
            else
            {
                Console.WriteLine("\nThere are no perfect matches available.\nBelow is a table with nannys available on some of the times " + child.First_Name + " needs.\n" +
                                  "Please enter the number representing the nanny you'd like to set up with " + child.First_Name + ":\n");
            }

            counter = 0;
            Console.WriteLine(" \t{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}\n", "First Name", "Last Name", "ID", "Distance", "Price");
            foreach (Nanny n in available_nannies)
            {
                Console.WriteLine(++counter + "\t{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", n.First_Name, n.Family_Name, n.Id,
                                  bl.get_distance(mother.Home_Address, n.Address) + " KM", ((n.Hourly_Price_Exists) ? (n.Hourly_Price + "(hourly)") : (n.Monthly_Price + "(monthly)")));
            }

            counter = 0;
            Console.WriteLine("\nHere is a list of Pros & Cons for each nanny to help you decide:\n");
            foreach (Nanny n in available_nannies)
            {
                Console.WriteLine(++counter + "\t{0} {1}:", n.First_Name, n.Family_Name);
                Console.WriteLine(" \tPositives: {0}", bl.get_positives(n, child, mother));
                Console.WriteLine(" \tNegatives: {0}", bl.get_negatives(n, child, mother));
                Console.WriteLine((!(perfect_matches) ? " \tTiming issues: {0}\n" : "\n"), bl.get_timing_issues(n, child, mother));
            }

            Console.Write("\nI choose nanny num: ");
            selected_nanny = int.Parse(Console.ReadLine());
            var nanny = available_nannies[selected_nanny - 1];

            Console.Write("\nCreating new contract between: {0} and {1} {2}\n", child.First_Name, nanny.First_Name, nanny.Family_Name);
            Contract cont = new Contract();

            cont.Child_Id  = child.Id;
            cont.Mother_Id = mother.Id;
            cont.Nanny_Id  = nanny.Id;
            bl.add_contract(cont);
            Console.Write("New contract between {0} and {1} {2} has been created. contract num is {3}\n", child.First_Name, nanny.First_Name, nanny.Family_Name, cont.Number);
        }