private Person GetPersonByLastName(string lastName) { Person result = null; PersonRepository personRepo = _factory.CreatePersonRepository(); List <Person> candidates = personRepo.ListByLastName(lastName) as List <Person>; switch (candidates.Count) { case 0: FilmMessageBox box = new FilmMessageBox("The database knows no person with last name containing " + lastName); box.Show(); break; case 1: result = candidates[0]; break; default: result = ChooseOnePerson(candidates); break; } return(result); }
internal void ShowCountries() { FilmCountryRepository fcRepo = _factory.CreateFilmCountryRepository(); CountryRepository cRepo = _factory.CreateCountryRepository(); List <Guid> ids = fcRepo.ListCountryIdsForFilmId(CurrentFilm.Id) as List <Guid>; List <string> names = new List <string>(); foreach (Guid g in ids) { Country c = cRepo.GetById(g); names.Add(c.Name); } if (names.Count == 0) { FilmMessageBox box = new FilmMessageBox("There are as yet no countries defined for this film."); box.Show(); } else { StringChooser chooser = new StringChooser(names); chooser.Show(); } }
internal void Find() { StringiDalog dialog = new StringiDalog(); dialog.WhatText = "A country abbreviation"; dialog.ShowDialog(); if (dialog.Accept) { string abbreviation = dialog.YourString; var foundCountry = _countryRepository.GetByAbreviation(abbreviation); if (foundCountry != null) { CurrentCountry = foundCountry; CountryView view = new CountryView(CurrentCountry); view.Show(); } else { FilmMessageBox box = new FilmMessageBox("No known country has abbreviation " + abbreviation); box.Show(); } } }
private Person PersonToLookup() { Person result = null; StringiDalog dialog = new StringiDalog(); dialog.WhatText = "A partial Last Name"; dialog.ShowDialog(); if (dialog.Accept) { string lastName = dialog.YourString; PersonRepository personRepo = _factory.CreatePersonRepository(); List <Person> candidates = personRepo.ListByLastName(lastName) as List <Person>; switch (candidates.Count) { case 0: FilmMessageBox box = new FilmMessageBox("No known person has a last name containing " + lastName); box.Show(); break; case 1: result = candidates[0]; break; default: List <string> nameList = NameList(candidates); StringChooser chooser = new StringChooser(nameList); chooser.ShowDialog(); if (chooser.Accepted) { string fullName = chooser.ChosenString; result = personRepo.GetByFullName(fullName); } break; } } return(result); }
private void ReportIt(string message) { FilmMessageBox box = new FilmMessageBox(message); box.Show(); }