private void CreatePost_CLick(object sender, RoutedEventArgs e) { try { PostElements myPost = new PostElements(tbxMyPostId.Text, tbxMyPostName.Text, tbxMyPostContent.Text, Convert.ToDateTime(tbxMyPostDate.Text), Convert.ToInt32(tbxMyPostLikes.Text), tbxMyPostComments.Text.Split(' ').ToList(), tbxMyPostUserId.Text); collection_posts.InsertOne(myPost); ReadAllMyPosts(); } catch { MessageBox.Show("No difference detected! Please change post id at least!"); } }
private void dgMyPosts_MouseUp(object sender, MouseButtonEventArgs e) { List <PostElements> list = collection_posts.AsQueryable().ToList <PostElements>(); PostElements myPost = (PostElements)dgMyPosts.SelectedItem; tbxMyPostId.Text = myPost.Id.ToString(); tbxMyPostName.Text = myPost.name; tbxMyPostContent.Text = myPost.content; tbxMyPostDate.Text = myPost.date.ToString(); tbxMyPostUserId.Text = myPost.user_id; tbxMyPostLikes.Text = myPost.likes.ToString(); tbxMyPostComments.Clear(); foreach (var comment in myPost.comments) { tbxMyPostComments.AppendText(comment + " "); } }
private void dgPosts_MouseUp(object sender, MouseButtonEventArgs e) { PostElements post = (PostElements)dgPosts.SelectedItem; tbxPostId.Text = post.Id.ToString(); tbxPostName.Text = post.name; tbxPostContent.Text = post.content; tbxPostdate.Text = post.date.ToString(); tbxPostComment.Clear(); foreach (var comment in post.comments) { tbxPostComment.AppendText(comment + " "); } tbxPostlikes.Text = post.likes.ToString(); tbxPostUser.Text = post.user_id; tbxPostLeaveComment.Clear(); SortDataGrid(dgPosts, 3, ListSortDirection.Descending); }
public void ReadAllMyPosts() { //List<PostElements> list1 = new List<PostElements>(); List <PostElements> myPostData = collection_posts.AsQueryable().Where(e => e.user_id == loggedUserId).ToList(); dgMyPosts.ItemsSource = myPostData; PostElements myPost = (PostElements)dgMyPosts.Items.GetItemAt(0); tbxMyPostId.Text = myPost.Id.ToString(); tbxMyPostName.Text = myPost.name; tbxMyPostContent.Text = myPost.content; tbxMyPostDate.Text = myPost.date.ToString(); tbxMyPostUserId.Text = myPost.user_id; tbxMyPostLikes.Text = myPost.likes.ToString(); tbxMyPostComments.Clear(); foreach (var comment in myPost.comments) { tbxMyPostComments.AppendText(comment + " "); } }
public void ReadAllPosts() { List <PostElements> list = collection_posts.AsQueryable().ToList <PostElements>(); dgPosts.ItemsSource = list; PostElements post = (PostElements)dgPosts.Items.GetItemAt(0); tbxPostId.Text = post.Id.ToString(); tbxPostName.Text = post.name; tbxPostContent.Text = post.content; tbxPostdate.Text = post.date.ToString(); tbxPostComment.Clear(); foreach (var comment in post.comments) { tbxPostComment.AppendText(comment + " "); } tbxPostlikes.Text = post.likes.ToString(); tbxPostUser.Text = post.user_id; tbxPostLeaveComment.Clear(); }