예제 #1
0
        public PetGenderRegistrations ProduceDailyCatGenderReassignments()
        {
            var result = new PetGenderRegistrations();

            var people = repository.GetAll();

            var groupedPeople = people.GroupBy(person => person.Gender);

            foreach (var grouping in groupedPeople)
            {
                var catsInGroup = grouping.SelectMany(person => person.Pets.Where(pet => pet.Type == PetType.Cat));
                result.Add(grouping.Key, catsInGroup.Select(cat => cat.Name).OrderBy(n => n));
            }

            return(result);
        }
예제 #2
0
        public void DisplayPetGenderRegistry(PetGenderRegistrations registrations)
        {
            foreach (var genderEntry in registrations)
            {
                Console.WriteLine(genderEntry.Key.ToString());
                Console.WriteLine(new string('-', genderEntry.Key.ToString().Length));

                foreach (var name in genderEntry.Value)
                {
                    Console.WriteLine(name);
                }

                Console.WriteLine();
            }

            Console.ReadLine();
        }