Beispiel #1
0
        // this the filtering logic
        private void performFiltering()
        {
            if (_filter == null)
            {
                _filter = "";
            }
            var newfilter = filter.ToLower().Trim();
            var result    = _Namedays.Where(d => d.nameAsString.ToLowerInvariant().Contains(newfilter)).ToList();
            var toremove  = _Namedays.Except(result).ToList();

            foreach (var x in result)
            {
                Namedays.Remove(x);
            }
            var resultcount = result.Count();

            for (int i = 0; i < resultcount; i++)
            {
                var resultItem = result[i];
                if (i + 1 > Namedays.Count || !Namedays[i].Equals(resultItem))
                {
                    Namedays.Insert(i, resultItem);
                }
            }
        }
Beispiel #2
0
        private void PerformFiltering()
        {
            if (_filter == null)
            {
                _filter = "";
            }

            var lowerCaseFilter = Filter.ToLowerInvariant().Trim();

            var result =
                _allNamedays.Where(d => d.NamesAsString.ToLowerInvariant()
                                   .Contains(lowerCaseFilter))
                .ToList();

            var toRemove = Namedays.Except(result).ToList();

            foreach (var x in toRemove)
            {
                Namedays.Remove(x);
            }

            var resultCount = result.Count;

            for (int i = 0; i < resultCount; i++)
            {
                var resultItem = result[i];
                if (i + 1 > Namedays.Count || !Namedays[i].Equals(resultItem))
                {
                    Namedays.Insert(i, resultItem);
                }
            }
        }
Beispiel #3
0
 // public void AddBirthdayToUser(int birthdayId, int userId)
 // {
 //     Users.FirstOrDefault((u) => u.TelegramId == userId).WatchedBirthdays.Add(birthdayId);
 //     SaveChanges();
 // }
 public void AddNamedayToUser(int namedayId, int userId)
 {
     Users.FirstOrDefault((u) => u.TelegramId == userId).WatchedNamedays.Add(Namedays.FirstOrDefault((n) => n.Id == namedayId));
     SaveChanges();
 }