Exemplo n.º 1
0
        //used to filter the places list
        private void PreformFiltering()
        {
            if (_filter == null)
            {
                _filter = "";
            }


            var lowerCaseFilter = Filter.ToLower().Trim();
            var result          =
                AllPlaces.Where(d => d.Name.ToLower()
                                .Contains(lowerCaseFilter)).ToList();

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

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


            var resultCount = result.Count;

            for (int i = 0; i < resultCount; i++)
            {
                var resultItem = result[i];
                if (i + 1 > Places.Count || !Places[i].Equals(resultItem))
                {
                    Places.Insert(i, resultItem);
                }
            }
        }