private void onClick(object sender, RoutedEventArgs e) { if (postList.SelectedItem != null) { int selectedIndex = Int32.Parse(postList.SelectedValue.ToString().Split()[0]); var context = new Model1Container(); Posts post = context.Posts.Find(selectedIndex); TextRange range = new TextRange(textContent.Document.ContentStart, textContent.Document.ContentEnd); post.Body = range.Text; context.SaveChanges(); } }
private void addUser_clicked(object sender, RoutedEventArgs e) { var context = new Model1Container(); var user = new Users() { Email = emailTextBox.Text, Password = passwordTextBox.Password, Username = usernameTextBox.Text }; context.Users.Add(user); context.SaveChanges(); emailTextBox.Clear(); passwordTextBox.Clear(); usernameTextBox.Clear(); }
public void Dispose() { context.SaveChanges(); }