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 Filter CreateFilter(IFilterEdit filter, QuickFilters quickFilter) { return new Filter { ProcessSystemName = filter.ProcessSystemName, Id = filter.Id, Name = filter.Name, FilterDefinition = ConvertMemberTypesToDataTypes(filter.FilterDefinition), IsAdminFilter = filter.IsAdminFilter ?? false, LayoutId = ToNullable(filter.DefaultLayout), QuickFilter = quickFilter }; }