Beispiel #1
0
        private void RefreshItems(SavedSearchesConfigFile savedSearches)
        {
            var searches = savedSearches
                           .OrderBy(s => s.Alias)
                           .Select(s => new SavedSearchModel(s, LoadItem, DeleteItem));

            using (SavedSearches.EnterMassUpdate())
            {
                SavedSearches.Clear();
                SavedSearches.AddRange(searches);
            }

            void LoadItem(SavedSearchModel item) =>
            _relay.Send(this, new SearchChangedMessage {
                SearchTags = item.Tags
            });

            async void DeleteItem(SavedSearchModel item)
            {
                var configs = SavedSearchConfigs;

                configs.Remove(item.Config);
                await SaveAndRefreshAsync(configs);
            }
        }
Beispiel #2
0
        private async Task SaveAndRefreshAsync(List <SavedSearchConfig> searches)
        {
            var fullConfig = new SavedSearchesConfigFile(searches);

            await _store.StoreAsync(fullConfig);

            RefreshItems(fullConfig);
        }
Beispiel #3
0
        private async Task <SavedSearchesModel> InitializeModel()
        {
            _store = new Mock <IConfigStore>();
            _relay = new Mock <IMessageRelay>();

            var config = new SavedSearchesConfigFile
            {
                new SavedSearchConfig {
                    Alias = "Test", Tags = { "Test1", "Test2" }
                }
            };

            _store.Setup(s => s.LoadAsyncOrDefault <SavedSearchesConfigFile>()).ReturnsAsync(config);

            var model = new SavedSearchesModel(_store.Object, _relay.Object);
            await model.InitializeAsync();

            return(model);
        }