public void createVaultnumber(vaultnumber vaultnumber) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { db.vaultnumber.Add(vaultnumber); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void NewAction(object commandParam) { vaultnumber newvault = new vaultnumber(); Vaults.Add(newvault); SelectedItem = newvault; }
public void updateVaultnumber(vaultnumber vaultnumber) { if (vaultnumber.vaultnumber_id != 0) { using (var db = new DataContext()) { var query = from qvaultnumber in db.vaultnumber where qvaultnumber.vaultnumber_id == vaultnumber.vaultnumber_id select qvaultnumber; foreach (vaultnumber evaultnumber in query) { evaultnumber.code = vaultnumber.code; evaultnumber.description = vaultnumber.description; evaultnumber.difficulty = vaultnumber.difficulty; evaultnumber.male_female = vaultnumber.male_female; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else { createVaultnumber(vaultnumber); } }