Ejemplo n.º 1
0
        /// <summary>
        /// Handles the creation of forum posts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StatusButton_Click(object sender, RoutedEventArgs e)
        {
            //Access the post window
            PostWindow postWindow = new PostWindow();

            //We can use the blog control for forums
            postWindow.theBlogPostControl.Visibility   = Visibility.Visible;
            postWindow.theLinksControl.Visibility      = Visibility.Hidden;
            postWindow.theStatusPostControl.Visibility = Visibility.Hidden;

            try
            {
                postWindow.theBlogPostControl.TitleBox.Text = "Enter your forum post title.";

                postWindow.ShowDialog();
                //Get the title of the post.
                string title = postWindow.theBlogPostControl.PostTitle;
                string body  = postWindow.theBlogPostControl.PostBody;

                MakeAForumPost(title, body, FID);
            }
            catch (Exception t)
            {
                MessageBox.Show(t.Message);
            }
        }
        /// <summary>
        /// Fires when the user clicks on Add a Comment, on the status page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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;

            Datum datum = (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 post your comment at this time. Please try again later.";
                }
                //MessageBox.Show("Unable to comment at this time.");
            }
        }
Ejemplo n.º 3
0
        private async void EditButton_Click(object sender, RoutedEventArgs e)
        {
            string tkBuild = "Bearer " + Token;

            Button editButton = sender as Button;
            Datum  datum      = (Datum)editButton.DataContext;

            if (datum != null)
            {
                PostWindow postWindow = new PostWindow();

                //Get the post ID.
                int postID = datum.id;
                //Since this is a status post, only the body is needed.
                string body  = datum.body;
                string title = datum.title;
                postWindow.theStatusPostControl.Visibility = Visibility.Hidden;
                postWindow.theBlogPostControl.Visibility   = Visibility.Visible;
                postWindow.theLinksControl.Visibility      = Visibility.Hidden;

                //First clear the textbox
                postWindow.theStatusPostControl.RTBox.Document.Blocks.Clear();
                postWindow.theBlogPostControl.TitleBox.Clear();
                //Append the message to be edited to the rich text box.

                postWindow.theBlogPostControl.RTBox.AppendText(body);
                postWindow.theBlogPostControl.TitleBox.Text = title;
                //We are ready for edit.
                postWindow.ShowDialog();

                string returnEditedText = postWindow.theBlogPostControl.PostBody;
                string EditedTitle      = postWindow.theBlogPostControl.PostTitle;

                string editEndpoint = @"https://api.africoders.com/v1/edit/post" + "?id=" + postID + "&title=" + EditedTitle + "&body=" + returnEditedText;

                postHelper            = new PostHelper(editEndpoint);
                loadingTextBlock.Text = "Editing post...";

                await postHelper.MakePostAsync(tkBuild);

                //MessageBox.Show("Post edited successfully.");

                loadingTextBlock.Text = "Post edited.";

                //Refresh
                Refresh();
            }
        }
Ejemplo n.º 4
0
        private void StatusButton_Click(object sender, RoutedEventArgs e)
        {
            PostWindow postWindow = new PostWindow();

            postWindow.titleText.Text                  = "Share a link with us";
            postWindow.theLinksControl.Visibility      = Visibility.Visible;
            postWindow.theBlogPostControl.Visibility   = Visibility.Hidden;
            postWindow.theStatusPostControl.Visibility = Visibility.Hidden;

            postWindow.ShowDialog();
            string title = postWindow.theLinksControl.Title;
            string body  = postWindow.theLinksControl.Body;
            string url   = postWindow.theLinksControl.URL;

            MakePost(body, title, url);
        }
Ejemplo n.º 5
0
        private void StatusButton_Click(object sender, RoutedEventArgs e)
        {
            PostWindow postWindow = new PostWindow();

            postWindow.titleText.Text = "Submit a job Advert.";
            postWindow.theBlogPostControl.Visibility   = Visibility.Visible;
            postWindow.theStatusPostControl.Visibility = Visibility.Hidden;
            postWindow.theLinksControl.Visibility      = Visibility.Hidden;

            postWindow.ShowDialog();
            //Since the blog post and job advert post are similar, they can effectively sgare the same control.
            string title = postWindow.theBlogPostControl.PostTitle;
            string body  = postWindow.theBlogPostControl.PostBody;

            MakePost(body, title);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the update of user posts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void EditButton_Click(object sender, RoutedEventArgs e)
        {
            PostWindow postWindow = new PostWindow();
            string     tokenBuild = "Bearer " + Token;
            Button     btn        = sender as Button;

            ForumModel.Datum datum = (ForumModel.Datum)btn.DataContext;

            if (datum != null)
            {
                postWindow.theBlogPostControl.Visibility   = Visibility.Visible;
                postWindow.theStatusPostControl.Visibility = Visibility.Hidden;
                postWindow.theLinksControl.Visibility      = Visibility.Hidden;


                postWindow.titleText.Text = "Edit your forum post";
                //Reformat the titleBox to reflect the current text.
                postWindow.theBlogPostControl.TitleBox.Text = datum.title;

                string bodyConverted = datum.body;
                //Clear the TB
                postWindow.theBlogPostControl.RTBox.Document.Blocks.Clear();

                postWindow.theBlogPostControl.RTBox.AppendText(bodyConverted);

                postWindow.ShowDialog();
                string editedTitle = postWindow.theBlogPostControl.PostTitle;
                string editedBody  = postWindow.theBlogPostControl.PostBody;

                int    id       = datum.id;
                string endpoint = @"https://api.africoders.com/v1/edit/post?id=" + id.ToString() + "&title=" + editedTitle + "&body=" + editedBody;

                postHelper            = new PostHelper(endpoint);
                loadingTextBlock.Text = "Editing Post.";
                await postHelper.MakePostAsync(tokenBuild);

                if (postHelper.StatusPostSuccessful)
                {
                    loadingTextBlock.Text = "Edited Post Successfully.";
                    Refresh();
                }
                else
                {
                    loadingTextBlock.Text = "Unable to edit post. Please try again.";
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Fires when the user intends to make a comment.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void CommentButton_Click(object sender, RoutedEventArgs e)
        {
            string tkBuild = "Bearer " + Token;

            Button btn = sender as Button;

            ForumModel.Datum datum = (ForumModel.Datum)btn.DataContext;

            if (datum != null)
            {
                int Id = datum.id;
                commentPoster = new CommentPoster();
                PostWindow postWindow = new PostWindow();

                postWindow.theStatusPostControl.Visibility = Visibility.Visible;
                postWindow.theLinksControl.Visibility      = Visibility.Hidden;
                postWindow.theBlogPostControl.Visibility   = Visibility.Hidden;
                postWindow.ShowDialog();

                string comment = postWindow.theStatusPostControl.Body;


                loadingTextBlock.Text = "Making a comment...";

                await commentPoster.MakeAComment(tkBuild, Id, comment);

                if (commentPoster.success)
                {
                    loadingTextBlock.Text = "Commented Successfully.";
                    Refresh();
                }
                else
                {
                    loadingTextBlock.Text = "Unable to post your comment.";
                    //MessageBox.Show("Unable to comment at this time.");
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the creation of blog posts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StatusButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PostWindow postWin = new PostWindow();
                postWin.theBlogPostControl.Visibility   = Visibility.Visible;
                postWin.theStatusPostControl.Visibility = Visibility.Hidden;
                postWin.theLinksControl.Visibility      = Visibility.Hidden;
                postWin.titleText.Text = "Share a blog post!";

                postWin.ShowDialog();

                string title = postWin.theBlogPostControl.PostTitle;
                string body  = postWin.theBlogPostControl.PostBody;

                MakeBlogPost(title, body);
            }

            catch
            {
                MessageBox.Show("Unable to complete the operation at this time.");
            }
        }
        /// <summary>
        /// Handles the making of statuses.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StatusButton_Click(object sender, RoutedEventArgs e)
        {
            PostWindow postWindow = new PostWindow();


            postWindow.titleText.Text = "What is on your mind right now?";


            //Set the visibility of controls.
            postWindow.theBlogPostControl.Visibility   = Visibility.Hidden;
            postWindow.theStatusPostControl.Visibility = Visibility.Visible;
            postWindow.theLinksControl.Visibility      = Visibility.Hidden;
            postWindow.ShowDialog();


            string message = postWindow.theStatusPostControl.Body;

            loadingTextBlock.Text = "Creating a status post..";
            //pass in the message.
            MakePost(message);

            //release valuable resources
            postWindow.Close();
        }