private async void CommentButton_Click(object sender, RoutedEventArgs e) { //The logged in user can make a comment by simply clicking this button. Button btn = sender as Button; AfricoderJobsFeed.Datum datum = (AfricoderJobsFeed.Datum)btn.DataContext; if (datum != null) { commentPoster = new CommentPoster(); PostWindow postWindow = new PostWindow(); postWindow.titleText.Text = "Add a comment"; postWindow.theStatusPostControl.Visibility = Visibility.Visible; postWindow.theLinksControl.Visibility = Visibility.Hidden; postWindow.theBlogPostControl.Visibility = Visibility.Hidden; postWindow.ShowDialog(); string tkBuild = "Bearer " + Token; string comment = postWindow.theStatusPostControl.Body; loadingTextBlock.Text = "Making a comment..."; await commentPoster.MakeAComment(tkBuild, datum.id, comment); if (commentPoster.success == true) { loadingTextBlock.Text = "Commented Successfully."; Refresh(); } else { loadingTextBlock.Text = "Unable to comment at this time."; } } }
private void Button_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; AfricoderJobsFeed.Datum data = btn.DataContext as AfricoderJobsFeed.Datum; //Load up the category window. CategoryDetailsWindow categoryDetailsWindow = new CategoryDetailsWindow(); if (data != null) { BlogDetailsWindow blogDetailsWindow = new BlogDetailsWindow(); blogDetailsWindow.headerTB.Text = "A job post by: " + data.user.name; //Clean the title and body string theTitle = data.title; string theBody = data.body; string cleanedTitle = Regex.Replace(theTitle, @"<[^>]*>", ""); string cleanedBody = Regex.Replace(theBody, @"<[^>]*>", ""); blogDetailsWindow.titleText.Text = cleanedTitle; blogDetailsWindow.bodyTB.Text = cleanedBody; blogDetailsWindow.userImage.Source = new BitmapImage(new Uri(data.user.avatarUrl)); blogDetailsWindow.dateText.Text = data.created.date; blogDetailsWindow.usernameText.Text = data.user.name; foreach (var dat in data.comment.data) { string comment = Regex.Replace(dat.body, @"<[^>]*>", ""); dat.body = comment; DateTime dateTime = new DateTime(); bool dateParse = DateTime.TryParse(dat.created.date, out dateTime); //string date = dat.created.date; if (dateParse) { string convertedTime = Convert.ToDateTime(DateTime.Parse(dateTime.ToString())).ToString(("ddd, dd MMM yyyy hh:mm:tt")); dat.created.date = convertedTime; } //Pass in the ID of the logged in user. dat.LoggedInID = LoggedId; } //Pass the slug blogDetailsWindow.PostSlug = data.slug; //pass the token blogDetailsWindow.Token = Token; blogDetailsWindow.commentsListBox.ItemsSource = data.comment.data; blogDetailsWindow.Show(); } }