private bool CandidatesViewFilter(object item)
        {
            if (string.IsNullOrEmpty(FirstNameFilter) &&
                CvUploaded == null
                &&
                string.IsNullOrEmpty(LastNameFilter) &&
                string.IsNullOrEmpty(PositionNameFilter) &&
                string.IsNullOrEmpty(PhoneNumberFilter) &&
                ConfigProjectsLibsView.Cast <ConfigProjectsLib>().ToList().Where(e => e.Selected.Equals(true)).Count() == ConfigProjectsLibsView.SourceCollection.Cast <ConfigProjectsLib>().ToList().Count() &&
                ConfigCompanyCollectionView.Cast <ConfigCompany>().ToList().Where(e => e.Selected.Equals(true)).Count() == ConfigCompanyCollectionView.SourceCollection.Cast <ConfigCompany>().ToList().Count()
                )
            {
                return(true);
            }
            else
            {
                if (
                    (string.IsNullOrEmpty(FirstNameFilter) || (((Candidate)item).FirstName.ToLower()).StartsWith(FirstNameFilter.ToLower())) &&
                    (string.IsNullOrEmpty(LastNameFilter) || (((Candidate)item).LastName.ToLower()).StartsWith(LastNameFilter.ToLower())) &&
                    (string.IsNullOrEmpty(PhoneNumberFilter) ||
                     (((Candidate)item).FirstPhone.ToLower().Trim()).StartsWith(PhoneNumberFilter.ToLower().Trim()) ||
                     (((Candidate)item).SecondPhone.ToLower().Trim()).StartsWith(PhoneNumberFilter.ToLower().Trim())
                    ) &&
                    (CvUploaded == null || CvUploaded.Equals(((Candidate)item).CvUploaded))

                    &&

                    (
                        (
                            ConfigProjectsLibsView.Cast <ConfigProjectsLib>().ToList().Where(e => e.Selected.Equals(true)).Count() == ConfigProjectsLibsView.SourceCollection.Cast <ConfigProjectsLib>().ToList().Count() &&
                            ConfigAreaView.Cast <ConfigArea>().ToList().Where(e => e.Selected.Equals(true)).Count() == ConfigAreaView.SourceCollection.Cast <ConfigArea>().ToList().Count() &&
                            ConfigCompanyCollectionView.Cast <ConfigCompany>().ToList().Where(e => e.Selected.Equals(true)).Count() == ConfigCompanyCollectionView.SourceCollection.Cast <ConfigCompany>().ToList().Count()
                        )
                        ||
                        (
                            ((Candidate)item).CandidateProjects.Join((ConfigProjectsLibsView.Cast <ConfigProjectsLib>().Where(e => e.Selected.Equals(true))).ToList(), cp => cp.ConfigProjectLibID, cpl => cpl.Id, (cp, cpl) => cp.ConfigCandidateID).ToList().Count > 0
                            &&
                            ((Candidate)item).CandidateProjects.Join((ConfigCompanyCollectionView.Cast <ConfigCompany>().Where(e => e.Selected.Equals(true))).ToList(), cc => cc.CompanyId, ccc => ccc.ID, (cc, ccc) => cc).ToList().Count > 0

                        )

                    )
                    &&
                    (string.IsNullOrEmpty(PositionNameFilter)
                     ||
                     ((Candidate)item).CandidateProjects.Where(e => e.Position.ToLower().Contains(PositionNameFilter.ToLower())).Count() > 0
                    )

                    )
                {
                    return(true);
                }

                return(false);
            }
        }
        private async void FilterData(object obj)
        {
            Window mainWindow = (Window)obj;
            List <Specification <People> > SpecList = new List <Specification <People> >();
            CheckBox DateCheck    = mainWindow.FindName("FilterByDateCheck") as CheckBox;
            CheckBox NameCheck    = mainWindow.FindName("FilterByNameCheck") as CheckBox;
            CheckBox LNameCheck   = mainWindow.FindName("FilterByLastNameCheck") as CheckBox;
            CheckBox SNameCheck   = mainWindow.FindName("FilterBySurNameCheck") as CheckBox;
            CheckBox CityCheck    = mainWindow.FindName("FilterByCityCheck") as CheckBox;
            CheckBox CountryCheck = mainWindow.FindName("FilterByCountryCheck") as CheckBox;

            if (DateCheck.IsChecked == true)
            {
                if (DateFilter == null || DateFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "DateFilter");
                }
                else
                {
                    SpecList.Add(new FindByDateSpecification(DateTime.Parse(DateFilter)));
                }
            }

            if (NameCheck.IsChecked == true)
            {
                if (NameFilter == null || NameFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "NameFilter");
                }
                else
                {
                    SpecList.Add(new FindByNameSpecification(NameFilter));
                }
            }
            if (LNameCheck.IsChecked == true)
            {
                if (LastNameFilter == null || LastNameFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "LastNameFilter");
                }
                else
                {
                    SpecList.Add(new FindByLastNameSpecification(LastNameFilter));
                }
            }
            if (SNameCheck.IsChecked == true)
            {
                if (SurNameFilter == null || SurNameFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "SurNameFilter");
                }
                else
                {
                    SpecList.Add(new FindBySurNameSpecification(SurNameFilter));
                }
            }
            if (CityCheck.IsChecked == true)
            {
                if (CityFilter == null || CityFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "CityFilter");
                }
                else
                {
                    SpecList.Add(new FindByCitySpecification(CityFilter));
                }
            }
            if (CountryCheck.IsChecked == true)
            {
                if (CountryFilter == null || CountryFilter.Replace(" ", "").Length == 0)
                {
                    EmptyFieldMessage(mainWindow, "CountryFilter");
                }
                else
                {
                    SpecList.Add(new FindByCountrySpecification(CountryFilter));
                }
            }
            if (SpecList.Count > 0)
            {
                Specification <People> specification = SpecList[0];
                SpecList.RemoveAt(0);
                foreach (var spec in SpecList)
                {
                    specification.And(spec);
                }
                using (IRepository <People> Repository = new PeopleRepository())
                    PeopleCollection = await Repository.Find(specification);
            }
            else
            {
                using (IRepository <People> Repository = new PeopleRepository())
                    PeopleCollection = await Repository.GetObjectsList();
            }
        }