private void BtnSave_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtLName.Text)) { try { using (var db = new mydbContext()) { //var data = new tbl_Users //{ // Name = txtName.Text, // LName = txtLName.Text, // Profile = createThumb(imgProfile.Source as BitmapImage) //}; //db.tbl_Users.Add(data); //db.SaveChanges(); CallInsert(txtName.Text, txtLName.Text, createThumb(imgProfile.Source as BitmapImage)); MainWindow.main.showNotification(false, "Saved to Database"); } } catch (Exception) { MainWindow.main.showNotification(true, "Error"); } } else { MainWindow.main.showNotification(true, "Fill input"); } }
public void loadData() { using (var db = new mydbContext()) { dgv.ItemsSource = db.tbl_Users.ToList(); } }
public async Task <List <tbl_Users> > GetData() { var db = new mydbContext(); var data = db.tbl_Users.ToListAsync(); return(await data); }
private void SearchBar_SearchStarted(object sender, HandyControl.Data.FunctionEventArgs <string> e) { using (var db = new mydbContext()) { dgv.ItemsSource = db.tbl_Users.Where(x => x.NameX.Contains(txtSearch.Text) || x.LName.Contains(txtSearch.Text)).Select(x => x).ToList(); } }
public MainWindow() { InitializeComponent(); main = this; var db = new mydbContext(); db.Database.Migrate(); }
public void loadData() { using (var db = new mydbContext()) { var data = db.tbl_Users.ToList(); _initialData = data; dgv.ItemsSource = data; } }
public async Task <string> DeleteUser(int id) { var db = new mydbContext(); var delete = await db.tbl_Users.FindAsync(id); db.tbl_Users.Remove(delete); await db.SaveChangesAsync(); return("deleted"); }
public async Task <string> UpdateUser(int id, string name, string lname, byte[] profile) { var db = new mydbContext(); var edit = await db.tbl_Users.FindAsync(id); edit.NameX = name; edit.LName = lname; edit.Profile = profile; await db.SaveChangesAsync(); return("edited"); }
public async Task <string> InsertToUser(string name, string lname, byte[] profile) { var db = new mydbContext(); var data = new tbl_Users { NameX = name, LName = lname, Profile = profile }; db.tbl_Users.Add(data); await db.SaveChangesAsync(); return("user added"); }