Example #1
0
        public static void AnalyzeUserCommand()
        {
            Person    person    = ObjectProvider.MakePersonInstance();
            PhoneBook phonebook = ObjectProvider.MakePhonebookInstance();
            Number    number    = ObjectProvider.MakeNumberInstance();

            switch (UserCommand)
            {
            case "Show All":
                ShowAllInfos();
                break;

            case "Person New":
                person.Add();
                break;

            case "Person Edit":
                person.FindPerson().UpdatePersonTotally();
                break;

            case "Person Delete":
                person.Delete();
                break;

            case "Person View Info":
                person.PrintPersonNumbers();
                break;

            case "PhoneBook New":
                phonebook.Add();
                break;

            case "PhoneBook Edit":
                phonebook.UpdatePhonebook();
                break;

            case "PhoneBook Delete":
                phonebook.Delete();
                break;

            case "Number New":
                number.Add();
                break;

            case "Number Edit":
                number.UpdateNumber();
                break;

            case "Number Delete":
                number.Delete();
                break;

            case "exit":
                Console.WriteLine("\n\t\tSee you later.");
                break;

            default:
                break;
            }
        }
Example #2
0
        public int Add()
        {
            var       db         = ObjectProvider.MakeDbInstance();
            PhoneBook aPhonebook = ObjectProvider.MakePhonebookInstance();

            Console.Write("Enter phonebook's title: ");
            aPhonebook.Title = Console.ReadLine();
            Console.Write("Enter the id of belonging person: ");
            aPhonebook.PhonebookPersonId = int.Parse(Console.ReadLine());
            db.Add(aPhonebook);
            db.SaveChanges();
            return(aPhonebook.Id);
        }