public App() { InitializeComponent(); using (var db = new JFDbContext()) { db.Database.Migrate(); } }
public void InitList(string listName = null) { using (var db = new JFDbContext()) { if (listName == null) { UnitList = db.Units.ToList<OtherItem>(); ColorList = db.Colors.ToList<OtherItem>(); } else { switch (listName) { case "UnitList": UnitList = db.Units.ToList<OtherItem>(); break; case "ColorList": ColorList = db.Colors.ToList<OtherItem>(); break; } } } }
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(); } }