Пример #1
0
		private void Update(NameAndCount[] collections)
		{
			var collectionModels = collections.OrderByDescending(x => x.Count).Select(col => new CollectionModel()
			{
				Name = col.Name,
				Count = col.Count
			}).ToArray();

			Collections.Match(collectionModels, AfterUpdate);
		}
Пример #2
0
        private void Update(NameAndCount[] collections)
        {
            var collectionModels = collections.OrderByDescending(x => x.Count).Select(col => new CollectionModel(DatabaseCommands)
            {
                Name = col.Name,
                Count = col.Count
            }).ToArray();
            Collections.Match(collectionModels);

            if (SelectedCollection.Value == null)
                SelectedCollection.Value = collectionModels.FirstOrDefault();
        }
Пример #3
0
		private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
		{
            // update documents count

		    var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
		    var collections = Collections.OrderByDescending(model => model.Count).ToList();
            Collections = new BindableCollection<CollectionModel>(model => model.Name);
		    foreach (var collectionModel in collections)
		    {
		        Collections.Add(collectionModel);
		    }
		    
		    foreach (var collectionModel in Collections)
		    {
		        collectionModel.Count = nameToCount[collectionModel.Name];
		    }

			if (initialSelectedDatabaseName != null &&
				(SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
			{
				SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
			}

			if (SelectedCollection.Value == null)
				SelectedCollection.Value = Collections.FirstOrDefault();

            OnPropertyChanged(() => Collections);
		}