示例#1
0
        public ObservableCollection <PersonModel> AllPossibleMothers()
        {
            IObjectContainer db = Db4oFactory.OpenFile("person.data");
            ObservableCollection <PersonModel> possibleMothers = new ObservableCollection <PersonModel>();
            var allWomenInDatabase = db.QueryByExample(new PersonModel(EGender.Female));

            foreach (var woman in allWomenInDatabase)
            {
                possibleMothers.Add((PersonModel)woman);
            }
            db.Close();
            possibleMothers = PossibleMothersHelper.RemovePossiblyWrongImportedMothers(possibleMothers);
            if (BirthDate != null)
            {
                possibleMothers = PossibleMothersHelper.RemovePossiblyMothersWithWrongAge(possibleMothers, BirthDate.Value);
            }
            return(possibleMothers);
        }
示例#2
0
        public BindableCollection <PersonModel> AllPossibleMothers(PersonModel selectedPerson, DateTime birthDate)
        {
            IObjectContainer db = Db4oFactory.OpenFile("person.data");
            BindableCollection <PersonModel> possibleMothers = new BindableCollection <PersonModel>();
            var allWomenInDatabase = db.QueryByExample(new PersonModel(EGender.Female));

            foreach (var woman in allWomenInDatabase)
            {
                possibleMothers.Add((PersonModel)woman);
            }
            db.Close();
            possibleMothers = PossibleMothersHelper.RemovePossiblyWrongImportedMothers(possibleMothers) as BindableCollection <PersonModel>;
            if (selectedPerson != null)
            {
                possibleMothers = PossibleMothersHelper.RemovePossiblyMothersWithWrongAge(possibleMothers, birthDate) as BindableCollection <PersonModel>;
                possibleMothers = PossibleMothersHelper.RemoveDescendantsFromPossibleMothers(possibleMothers, selectedPerson) as BindableCollection <PersonModel>;
            }
            possibleMothers.Add(new PersonModel("-brak-"));
            return(possibleMothers);
        }
示例#3
0
        public BindableCollection <PersonModel> AllPossibleMothers(PersonModel person)
        {
            IObjectContainer db = Db4oFactory.OpenFile("person.data");
            BindableCollection <PersonModel> possibleMothers = new BindableCollection <PersonModel>();
            var allWomenInDatabase = db.QueryByExample(new PersonModel(EGender.Female));

            foreach (var man in allWomenInDatabase)
            {
                possibleMothers.Add((PersonModel)man);
            }
            db.Close();
            List <PersonModel> womenWithBirthDate = new List <PersonModel>();

            foreach (var woman in possibleMothers)
            {
                if (woman.BirthDate != null)
                {
                    womenWithBirthDate.Add(woman);
                }
            }
            foreach (var woman in womenWithBirthDate)
            {
                possibleMothers.Remove(woman);
            }
            possibleMothers = PossibleMothersHelper.RemovePossiblyWrongImportedMothers(possibleMothers) as BindableCollection <PersonModel>;
            possibleMothers = PossibleMothersHelper.RemoveDescendantsFromPossibleMothers(possibleMothers, person) as BindableCollection <PersonModel>;
            var items = possibleMothers.Where(x => x.Name == person.Name);

            if (items != null)
            {
                foreach (var thisPerson in items.ToList())
                {
                    possibleMothers.Remove(thisPerson);
                }
            }
            possibleMothers.Add(new PersonModel("-brak-"));
            return(possibleMothers);
        }