Beispiel #1
0
        public List <PersonModel> ApplyFilter(PersonListActionOption option, string value)
        {
            int index = (int)option;

            _filteringFlags[index]  = true;
            _filteringValues[index] = value;
            return(Filter());
        }
Beispiel #2
0
        public List <PersonModel> RemoveFilter(PersonListActionOption option)
        {
            int index = (int)option;

            _filteringFlags[index]  = false;
            _filteringValues[index] = null;
            return(Filter());
        }
Beispiel #3
0
        public List <PersonModel> Sort(PersonListActionOption option)
        {
            int index = (int)option;

            _sortingFlags[index] = !_sortingFlags[index];
            PersonList.Sort((p1, p2) =>
            {
                int result = option switch
                {
                    PersonListActionOption.FirstName => p1.FirstName.CompareTo(p2.FirstName),
                    PersonListActionOption.LastName => p1.LastName.CompareTo(p2.LastName),
                    PersonListActionOption.BirthDate => p1.BirthDateDateTime.CompareTo(p2.BirthDateDateTime),
                    PersonListActionOption.Email => p1.Email.CompareTo(p2.Email),
                    PersonListActionOption.Adult => p1.IsAdult.CompareTo(p2.IsAdult),
                    PersonListActionOption.BirthDay => p1.IsBornToday.CompareTo(p2.IsBornToday),
                    PersonListActionOption.ChineseSign => p1.ChineseZodiacSign.name.CompareTo(p2.ChineseZodiacSign.name),
                    PersonListActionOption.WesternSign => p1.WesternZodiacSign.name.CompareTo(p2.WesternZodiacSign.name),
                    _ => - 1
                };
                return(_sortingFlags[index] ? result : -result);
            });
            return(Filter());
        }