public static void DeleteDB() { using (ContextoDatos db = new ContextoDatos()) { if (db.DatabaseExists()) { db.DeleteDatabase(); } } }
public static bool DatabaseExist() { using (ContextoDatos db = new ContextoDatos()) { return db.DatabaseExists(); } }
void loadUsers() { listBox1.ItemsSource = null; List<Usuario> listaUsuarios = new List<Usuario>(); ContextoDatos ctx = new ContextoDatos(); var data = ctx.Users.OrderBy(o => o.Nombre); if(ctx.DatabaseExists()) { foreach (User user in data) { listaUsuarios.Add(new Usuario { Id = user.Id, Nombre = user.Nombre }); } listBox1.ItemsSource = listaUsuarios; } }
public static void CrearDBSiNoExiste() { using (ContextoDatos db = new ContextoDatos()) { if (!db.DatabaseExists()) { db.CreateDatabase(); } } }
void loadUsers() { listBox1.ItemsSource = null; List<Usuario> listaUsuarios = new List<Usuario>(); ContextoDatos ctx = new ContextoDatos(); var data = ctx.Users.OrderBy(o=>o.Nombre); if(ctx.DatabaseExists()) { foreach(User user in data) { if((App.Current as App).CurrentUser.HasValue) { if(user.Id == (App.Current as App).CurrentUser.Value) listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre, Selected = true}); else listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre}); } else { listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre}); } } listBox1.ItemsSource = listaUsuarios; } }