private void SaveNewFilter(IFilterSetupViewModel filterSetupViewModel) { TheDynamicTypeManager.Value.BeginNewEditableRoot<IFilterEdit>( Constants.FilterProcessName, async (s, e) => { if (e.Error == null) { await SaveFilter(filterSetupViewModel, e.Object); } else { ThePopupFactory.Value.NotifyFailure(e.Error); } }); }
private async Task SaveFilter(IFilterSetupViewModel filterSetupViewModel, IFilterEdit filterEdit) { filterEdit.Name = filterSetupViewModel.Name; filterEdit.FilterDefinition = filterSetupViewModel.FilterDefinitions; filterEdit.ProcessSystemName = SearchViewModel.ProcessSystemName; filterEdit.DefaultLayout = filterSetupViewModel.DefaultLayoutId; if (string.IsNullOrWhiteSpace(filterEdit.Guid)) filterEdit.Guid = FilterDescriptor.GetFilterGuid(filterSetupViewModel.FilterDefinitions); var filterVm = FilterList.FirstOrDefault(l => l.Id == filterEdit.Id); filterEdit.Account = filterVm != null && filterVm.IsAdmin ? null : (int?)Utils.CurrentUserAccountId; try { // ReSharper disable SuspiciousTypeConversion.Global var edited = await ((ISavable)filterEdit).SaveAsync() as IFilterEdit; // ReSharper restore SuspiciousTypeConversion.Global if (edited != null) { QuickFilterToolbarVM.Value.SetQuickFilter(filterSetupViewModel.QuickFilter, edited.Id); } SelectedFilter = filterVm; if (SelectedFilter != null) { SelectedFilter.OriginalFilterDefinitions = filterSetupViewModel.FilterDefinitions; SelectedFilter.QuickFilter = filterSetupViewModel.QuickFilter; } ThePopupFactory.Value.NotifySuccess(SharedLocalizedStrings.Msg_FilterSaved); await RefreshFilters(); await QuickFilterToolbarVM.Value.RefreshQuickFilters(); } catch (Exception ex) { ThePopupFactory.Value.NotifyFailure(ex); } }
private static void Static(WeakEventListener<FilterListViewModel, IFilterSetupViewModel, PropertyChangedEventArgs> listener, IFilterSetupViewModel source) { source.PropertyChanged -= listener.OnEvent; }