private void RemoveCategoryCommandExecute(object obj) { CategoryWindow window = container.Resolve <CategoryWindow>(new ResolverOverride[] { new ParameterOverride("actionCode", 3) }); window.Owner = (obj as Window); bool result = (bool)window.ShowDialog(); if (result) { var removedCategory = (window.DataContext as CategoryWindowViewModel).DataFormCategory; var current = DataFormCategories.Where(s => s.CategoryId == removedCategory.CategoryId).FirstOrDefault(); if (current != null) { DataFormCategories.Remove(current); } } }
private void UpdateCategoryCommandExecute(object obj) { CategoryWindow window = container.Resolve <CategoryWindow>(new ResolverOverride[] { new ParameterOverride("actionCode", 2) }); window.Owner = (obj as Window); bool result = (bool)window.ShowDialog(); if (result) { var update = (window.DataContext as CategoryWindowViewModel).DataFormCategory; var current = DataFormCategories.Where(s => s.CategoryId == update.CategoryId).FirstOrDefault(); if (current != null) { current.CategoryName = update.CategoryName; current.Description = update.Description; } } }