Exemple #1
0
        internal void Find()
        {
            Person       foundPerson = null;
            StringDialog dialog      = new StringDialog("A partial last name");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string        lastName   = dialog.YourString;
                List <Person> candidates = _personRepository.ListByLastName(lastName);
                switch (candidates.Count)
                {
                case 0:
                    ReportIt("No person has last name " + lastName);
                    return;

                case 1:
                    foundPerson = candidates[0];
                    break;

                default:
                    foundPerson = ChooseAUniquePerson(candidates);
                    break;
                }
                PersonView view = new PersonView(this);
                view.Show();
            }
        }
        private Person GetPersonFor(string lastName)
        {
            Person result = null;
            AbstractPersonRepository pRepo      = _personRepository;
            List <Person>            candidates = pRepo.ListByLastName(lastName);

            switch (candidates.Count)
            {
            case 0:
                ReportIt("No known person has a laast name containing " + lastName);
                break;

            case 1:
                result = candidates[0];
                break;

            default:
                result = ChooseAUniquePerson(candidates, pRepo);
                break;
            }
            return(result);
        }