public IActionResult Save(EditFilterViewModel model) { if (ModelState.IsValid) { ICmsManager manager = CmsManager.Load(); if (model.Id == null) { IFilter filtermodel = FCms.Factory.FilterFactory.CreateFilterByType((IFilter.FilterType)Enum.Parse(typeof(IFilter.FilterType), model.Type)); manager.Filters.Add(model.MapToModel(filtermodel)); } else { int repoindex = manager.Filters.Select((v, i) => new { filter = v, Index = i }).FirstOrDefault(x => x.filter.Id == model.Id)?.Index ?? -1; if (repoindex < 0) { throw new Exception("The filter definition not found"); } model.MapToModel(manager.Filters[repoindex]); } manager.Save(); return(Redirect("/fcmsmanager/filter")); } return(View("Add", new EditFilterViewModel())); }
public EditFilterDialog(FilterContainer filter) { InitializeComponent(); FilterVM = new EditFilterViewModel(filter); this.DataContext = FilterVM; MainGrid.DataContext = FilterVM; m_OK = false; if (filter == null) { m_addingNew = true; } else { m_addingNew = false; } }
public EditFilterView() { InitializeComponent(); ViewModel = new EditFilterViewModel(); ViewModel.View = this; }