private void DeleteItem(string listName) { using (var db = new JFDbContext()) { switch (listName) { case "UnitList": var selectedUnit = new UnitItem(SelectedUnit); db.Units.Remove(selectedUnit); break; case "ColorList": var selectedColor = new ColorItem(SelectedColor); db.Colors.Remove(selectedColor); break; } db.SaveChanges(); // _ocvm.InitList(listName); InitOCVM(); } }
private void AddItem(string listName) { using (var db = new JFDbContext()) { switch (listName) { case "UnitList": var unitItem = new UnitItem(){ Name = UnitName }; db.Units.Add(unitItem); UnitName = ""; break; case "ColorList": var colorItem = new ColorItem(){ Name = ColorName }; db.Colors.Add(colorItem); ColorName = ""; break; } db.SaveChanges(); // OCVM.InitList(listName); InitOCVM(); } }