Ejemplo n.º 1
0
        private static void GetCategories()
        {
            foreach (var cat in contactManager.GetAllCategories())
            {
                Console.WriteLine(cat.PrintCategory());
            }
            bool categoryMatch = false;
            int  dkeuze;

            Console.WriteLine("geef de id in");
            if (Int32.TryParse(Console.ReadLine(), out dkeuze))
            {
                foreach (var cat in contactManager.GetAllCategories())
                {
                    if (cat.CategoryId == dkeuze)
                    {
                        categoryMatch = true;
                    }
                }
            }
            else
            {
                Console.WriteLine("ONGELDIGE WAARDE");
                return;
            }
            if (categoryMatch)
            {
                foreach (var contact in contactManager.GetAllContacts(OrderByFieldName.ID))
                {
                    foreach (var ct in contact.Categories)
                    {
                        if (ct.CategoryId == dkeuze)
                        {
                            string message =
                                $"Contact {contact.Name} is woonachtig te {contact.Adress.City} en is een {contact.Gender}";
                            Console.WriteLine(message);
                        }
                    }
                }
            }
        }