Exemplo n.º 1
0
        private void UpdateSortDefinitions(DataGridColumn updatedColumn)
        {
            // Not nullable, check if there already is a sort description for that column.
            if (_sortDescriptions.Any(i => i.PropertyName == updatedColumn.SortMemberPath))
            {
                // Get the description.
                var columnSortDescription =
                    _sortDescriptions.FirstOrDefault(i => i.PropertyName == updatedColumn.SortMemberPath);

                var columnSortDirection = updatedColumn.SortDirection;

                // Always remove from definitions, updating value throws an exception.
                _sortDescriptions.Remove(columnSortDescription);

                // If there is a direction, add the new value.
                if (columnSortDirection != null)
                {
                    _sortDescriptions.Add(
                        new SortDescription(updatedColumn.SortMemberPath, GetSortDirection(updatedColumn)));
                }
            }

            // Add column to definitions.
            else
            {
                _sortDescriptions.Add(
                    new SortDescription(updatedColumn.SortMemberPath, GetSortDirection(updatedColumn)));
            }

            UpdateColumnSortDefinitions();
        }
Exemplo n.º 2
0
        public void SetDefaultSorts(IEnumerable <SortDescription> sorts)
        {
            //TODO: add support for this
            if (_defaultSorts.Any())
            {
                throw new NotSupportedException("Already added default sorts");
            }

            foreach (var sort in sorts)
            {
                _defaultSorts.Add(new SortDescription(sort.PropertyName, sort.Direction));
            }
            ApplyDefaultSorts();
        }
        public IList <IImportJobViewModel> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            var retVal = new List <IImportJobViewModel>();

            using (var repository = _importRepository.GetRepositoryInstance())
            {
                var query = repository.ImportJobs;

                if (!string.IsNullOrEmpty(SearchFilterKeyword))
                {
                    query = query.Where(x => x.Name.Contains(SearchFilterKeyword));
                }
                else
                {
                    if (!string.IsNullOrEmpty(SearchFilterName))
                    {
                        query = query.Where(x => x.Name.Contains(SearchFilterName));
                    }
                }

                overallCount = query.Count();
                var orderedItems = !sortDescriptions.Any() ? query.OrderBy(x => x.Name) : ApplySortDescriptions(query, sortDescriptions);
                var items        = orderedItems.Skip(startIndex).Take(count).ToList();
                foreach (var item in items)
                {
                    if (AvailableImporters.Any(importer => importer.ToString() == item.EntityImporter))
                    {
                        var itemViewModel = _itemVmFactory.GetViewModelInstance(
                            new KeyValuePair <string, object>("item", item),
                            new KeyValuePair <string, object>("entityImporters", AvailableImporters),
                            new KeyValuePair <string, object>("homeMenuName", _parentViewModel.CurrentTab.IdTab)
                            );
                        retVal.Add(itemViewModel);
                    }
                    else
                    {
                        overallCount -= 1;
                    }
                }
            }
            return(retVal);
        }