Esempio n. 1
0
        public static IEnumerable <Model.Field> ToFields(this System.ComponentModel.SortDescriptionCollection sortDescriptionCollection)
        {
            IList <Model.Field> result = new List <Model.Field>();

            if (sortDescriptionCollection != null)
            {
                foreach (System.ComponentModel.SortDescription item in sortDescriptionCollection)
                {
                    result.Add(new Field(item.PropertyName)
                    {
                        SortDirection = item.Direction
                    });
                }
            }

            return(result);
        }
Esempio n. 2
0
        // set new SortDescription collection; rehook collection change notification handler
        private void SetSortDescriptions(SortDescriptionCollection descriptions)
        {
            if (_sort != null)
            {
                ((INotifyCollectionChanged)_sort).CollectionChanged -= new NotifyCollectionChangedEventHandler(SortDescriptionsChanged);
            }

            bool raiseChangeEvent = (_sort != descriptions);

            _sort = descriptions;

            if (_sort != null)
            {
                Invariant.Assert(_sort.Count == 0, "must be empty SortDescription collection");
                ((INotifyCollectionChanged)_sort).CollectionChanged += new NotifyCollectionChangedEventHandler(SortDescriptionsChanged);
            }

            if (raiseChangeEvent)
            {
                OnPropertyChanged(new PropertyChangedEventArgs("SortDescriptions"));
            }
        }
Esempio n. 3
0
        public IList <IRoleViewModel> LoadRange(int startIndex, int count, System.ComponentModel.SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            var retVal = new List <IRoleViewModel>();

            using (var repository = _repositoryFactory.GetRepositoryInstance())
            {
                var query = repository.Roles;

                if (!string.IsNullOrEmpty(SearchKeyword))
                {
                    query = query.Where(c => c.Name.Contains(SearchKeyword));
                }

                overallCount = query.Count();

                var results = query.OrderBy(c => c.RoleId).Skip(startIndex).Take(count).ToList();

                retVal.AddRange(results.Select(item => _itemVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item))));
            }

            return(retVal);
        }