Ejemplo n.º 1
0
        /// <summary>
        /// Filters Users based on the given citirions
        /// </summary>
        /// <param name="item"></param>
        /// <returns>if the given object is valid by filtering</returns>
        public bool FilterUsers(object item)
        {
            User user           = item as User;
            int  numOfevaluated = PropertiesToCheck();
            int  numOfValid     = 0;

            if (user != null)
            {
                if (ChbFirstName)
                {
                    if (user.FirstName.ToLower().Contains(TxtFirstName.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (ChbLastName)
                {
                    if (user.LastName.ToLower().Contains(TxtLastName.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (ChbEmail)
                {
                    if (user.Email.ToLower().Contains(TxtEmail.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (CurrentGender.ToString() == user.Gender)
                {
                    numOfValid++;
                }
                if (ChbCountry)
                {
                    if (user.Country.ToLower().Contains(TxtCountry.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (ChbCity)
                {
                    if (user.City.ToLower().Contains(TxtCity.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (ChbStreet)
                {
                    if (user.Street.ToLower().Contains(TxtStreet.ToLower()))
                    {
                        numOfValid++;
                    }
                }
                if (ChbPhoneNumber)
                {
                    if (user.PhoneNumber.ToLower().Contains(TxtPhoneNumber.ToLower()))
                    {
                        numOfValid++;
                    }
                }

                return(numOfevaluated == numOfValid);
            }

            return(false);
        }