Example #1
0
        private static void ContactUpdate()
        {
            Console.WriteLine("Kies eerst een van de onderstaande contacten:");
            foreach (var contact in contactManager.GetAllContacts(OrderByFieldName.ID))
            {
                Console.WriteLine($"{contact.ContactId} - {contact.Name}");
            }
            Console.Write("Van welke contact (id) wenst u de naam te wijzigen?");
            int  idKeuze;
            bool contactGevonden = false;

            if (int.TryParse(Console.ReadLine(), out idKeuze))
            {
                Console.Write("geef de nieuwe naam in: ");
                string naam = Console.ReadLine();
                foreach (Contact contact in contactManager.GetAllContacts(OrderByFieldName.ID))
                {
                    if (contact.ContactId == idKeuze)
                    {
                        contact.Name = naam;
                        contactManager.ChangeContact(contact);
                        contactGevonden = true;
                    }
                }
            }
            else
            {
                Console.WriteLine("ONGELDIGE WAARDE");
            }
            if (!contactGevonden)
            {
                Console.WriteLine("!!!Het gevraagde contact kan niet gevonden worden!!!");
            }
        }