Esempio n. 1
0
        internal void ShowContributors(Role role)
        {
            AbstractPersonRepository     pRepo  = _personRepository;
            AbstractFilmPersonRepository fpRepo = _filmPersonRepository;
            List <Guid>   ids   = fpRepo.ListPersonIdsForilmIdAndRole(CurrentFilm.Id, role);
            List <string> names = new List <string>();

            foreach (Guid id in ids)
            {
                Person p = pRepo.GetById(id);
                names.Add(p.FullName);
            }
            if (names.Count > 0)
            {
                StringChooser chooser = new StringChooser(names);
                chooser.Show();
            }
            else
            {
                string[] contribkind = { "contributors", "actors", "composers", "directors", "scriptwriters" };

                string kind = contribkind[(int)role];

                ReportIt("There are (as yet) no " + kind + " defined for this film");
            }
        }
Esempio n. 2
0
 public FilmListViewModel(MainWindow view)
 {
     _mainView              = view;
     _countryRepository     = view.CountryRepository;
     _filmCountryRepository = view.FilmCountryRepository;
     _filmPersonRepository  = view.FilmPersonRepository;
     _filmRepository        = view.FilmRepository;
     _locationRepository    = view.LocationRepository;
     _personRepository      = view.PersonRepository;
     Films       = new ObservableCollection <Film>(_filmRepository.List());
     CurrentFilm = _filmRepository.List().FirstOrDefault();
 }
        private List <Person> GetContributors(Role role)
        {
            List <Person> result = new List <Person>();
            AbstractFilmPersonRepository fpRepo = _view.FilmPersonRepository;
            AbstractPersonRepository     pRepo  = _view.PersonRepository;
            List <Guid> ids = fpRepo.ListPersonIdsForilmIdAndRole(Film.Id, role);

            foreach (Guid id in ids)
            {
                Person p = pRepo.GetById(id);
                result.Add(p);
            }
            return(result);
        }
Esempio n. 4
0
        private Person ChooseAUniquePerson(List <Person> candidates, AbstractPersonRepository pRepo)
        {
            Person        result    = null;
            List <string> fullNames = new List <string>();

            foreach (Person p in candidates)
            {
                fullNames.Add(p.FullName);
            }
            StringChooser chooser = new StringChooser(fullNames);

            chooser.ShowDialog();
            if (chooser.Accept)
            {
                result = pRepo.GetByFullName(chooser.ChosenString);
            }
            return(result);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public PersonListViewModel(MainWindow view)
 {
     _personRepository = view.PersonRepository;
     People            = new ObservableCollection <Person>(_personRepository.List());
     CurrentPerson     = _personRepository.List().FirstOrDefault();
 }
 static PersonRepository()
 {
     instance = new PersonRepository();
 }