Exemplo n.º 1
0
 public App()
 {
     InitializeComponent();
     using (var db = new JFDbContext())
     {
         db.Database.Migrate();
     }
 }
Exemplo n.º 2
0
 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;
             }
         }
     }
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
 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();
     }
 }