/// <summary> /// Returns true if the search input applies to the model /// </summary> public bool SearchInputApplies(BackgroundSearchInput searchInput, BackgroundModel backgroundModel) { return(HasSearchText(backgroundModel, searchInput.SearchText) && HasSkill(backgroundModel, searchInput.Skill.Key) && HasTool(backgroundModel, searchInput.Tool.Key) && HasLanguage(backgroundModel, searchInput.Language.Key)); }
/// <summary> /// Creates an instance of <see cref="BackgroundsViewModel"/> /// </summary> public BackgroundsViewModel(Compendium compendium, BackgroundSearchService backgroundSearchService, BackgroundSearchInput backgroundSearchInput, StringService stringService, DialogService dialogService, XMLImporter xmlImporter, XMLExporter xmlExporter) { _compendium = compendium; _backgroundSearchService = backgroundSearchService; _backgroundSearchInput = backgroundSearchInput; _stringService = stringService; _dialogService = dialogService; _xmlImporter = xmlImporter; _xmlExporter = xmlExporter; _selectBackgroundCommand = new RelayCommand(obj => true, obj => SelectBackground(obj as BackgroundListItemViewModel)); _editBackgroundCommand = new RelayCommand(obj => true, obj => EditBackground(obj as BackgroundViewModel)); _exportBackgroundCommand = new RelayCommand(obj => true, obj => ExportBackground(obj as BackgroundViewModel)); _cancelEditBackgroundCommand = new RelayCommand(obj => true, obj => CancelEditBackground()); _saveEditBackgroundCommand = new RelayCommand(obj => HasUnsavedChanges, obj => SaveEditBackground()); _resetFiltersCommand = new RelayCommand(obj => true, obj => InitializeSearch()); _addCommand = new RelayCommand(obj => true, obj => Add()); _copyCommand = new RelayCommand(obj => _selectedBackground != null, obj => Copy()); _deleteCommand = new RelayCommand(obj => _selectedBackground != null, obj => Delete()); _importCommand = new RelayCommand(obj => true, obj => Import()); _selectNextCommand = new RelayCommand(obj => true, obj => SelectNext()); _selectPreviousCommand = new RelayCommand(obj => true, obj => SelectPrevious()); Search(); }
/// <summary> /// Searches the compendium for backgrounds matching the search input /// </summary> public List <BackgroundModel> Search(BackgroundSearchInput searchInput) { return(Sort(_compendium.Backgrounds.Where(x => SearchInputApplies(searchInput, x)), searchInput.SortOption.Key)); }