public ObservableCollection <PersonModel> AllPossibleFathers() { IObjectContainer db = Db4oFactory.OpenFile("person.data"); ObservableCollection <PersonModel> possibleFathers = new ObservableCollection <PersonModel>(); var allMenInDatabase = db.QueryByExample(new PersonModel(EGender.Male)); foreach (var man in allMenInDatabase) { possibleFathers.Add((PersonModel)man); } db.Close(); possibleFathers = PossibleFathersHelper.RemovePossiblyWrongImportedFathers(possibleFathers); if (BirthDate != null) { possibleFathers = PossibleFathersHelper.RemovePossiblyFathersWithWrongAge(possibleFathers, BirthDate.Value); } return(possibleFathers); }
public BindableCollection <PersonModel> AllPossibleFathers(PersonModel selectedPerson, DateTime birthDate) { IObjectContainer db = Db4oFactory.OpenFile("person.data"); BindableCollection <PersonModel> possibleFathers = new BindableCollection <PersonModel>(); var allMenInDatabase = db.QueryByExample(new PersonModel(EGender.Male)); foreach (var man in allMenInDatabase) { possibleFathers.Add((PersonModel)man); } db.Close(); possibleFathers = PossibleFathersHelper.RemovePossiblyWrongImportedFathers(possibleFathers) as BindableCollection <PersonModel>; if (selectedPerson != null) { possibleFathers = PossibleFathersHelper.RemovePossiblyFathersWithWrongAge(possibleFathers, birthDate) as BindableCollection <PersonModel>; possibleFathers = PossibleFathersHelper.RemoveDescendantsFromPossibleFathers(possibleFathers, selectedPerson) as BindableCollection <PersonModel>; } possibleFathers.Add(new PersonModel("-brak-")); return(possibleFathers); }
public BindableCollection <PersonModel> AllPossibleFathers(PersonModel person) { IObjectContainer db = Db4oFactory.OpenFile("person.data"); BindableCollection <PersonModel> possibleFathers = new BindableCollection <PersonModel>(); var allMenInDatabase = db.QueryByExample(new PersonModel(EGender.Male)); foreach (var man in allMenInDatabase) { possibleFathers.Add((PersonModel)man); } db.Close(); List <PersonModel> menWithBirthDate = new List <PersonModel>(); foreach (var man in possibleFathers) { if (man.BirthDate != null) { menWithBirthDate.Add(man); } } foreach (var man in menWithBirthDate) { possibleFathers.Remove(man); } possibleFathers = PossibleFathersHelper.RemovePossiblyWrongImportedFathers(possibleFathers) as BindableCollection <PersonModel>; possibleFathers = PossibleFathersHelper.RemoveDescendantsFromPossibleFathers(possibleFathers, person) as BindableCollection <PersonModel>; var items = possibleFathers.Where(x => x.Name == person.Name); if (items != null) { foreach (var thisPerson in items.ToList()) { possibleFathers.Remove(thisPerson); } } items = null; possibleFathers.Add(new PersonModel("-brak-")); return(possibleFathers); }