Ejemplo n.º 1
0
        public virtual async Task <AfricodersBlogModel.Datum[]> GetNextBlogPosts(int currentIndex, int ID)
        {
            Endpoint          = Endpoint + currentIndex.ToString();
            africoderBlogFeed = new AfricoderBlogFeed();
            obtainer          = new JsonObtainer(Endpoint, "Blog Pagination Agent");
            string jsonresult = await obtainer.GetJsonStringAsync();

            africoderBlogFeed = JsonConvert.DeserializeObject <AfricoderBlogFeed>(jsonresult);

            foreach (var dat in africoderBlogFeed.data)
            {
                dat.LoggedInID = ID;
            }
            return(africoderBlogFeed.data);
        }
Ejemplo n.º 2
0
        public virtual async Task ManageBlogPostsAsync(JsonObtainer jsonObtainer, BlogFeedControl blogFeedControl, int ID)
        {
            string jsonResult = await jsonObtainer.GetJsonStringAsync();

            AfricoderBlogFeed africoderBlogFeed = JsonConvert.DeserializeObject <AfricoderBlogFeed>(jsonResult);

            if (jsonResult != string.Empty)
            {
                foreach (var result in africoderBlogFeed.data)
                {
                    string date = result.created.date;


                    string convertedTime = Convert.ToDateTime(DateTime.Parse(date)).ToString(("ddd, dd MMM yyyy hh:mm:tt"));
                    result.created.date = convertedTime;
                }

                foreach (var dat in africoderBlogFeed.data)
                {
                    dat.LoggedInID = ID;
                }
                blogFeedControl.TheLB.ItemsSource = africoderBlogFeed.data;
            }
        }
        /// <summary>
        /// Displays the Blogs page and hides other sections.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BlogButton_Click(object sender, RoutedEventArgs e)
        {
            SetThickness(BlogsButton);
            theProfilePage.Visibility            = Visibility.Hidden;
            temporaryBlogGrid.Visibility         = Visibility.Hidden;
            toolsControl.Visibility              = Visibility.Hidden;
            WelcomeControl.Visibility            = Visibility.Hidden;
            statusControl.Visibility             = Visibility.Hidden;
            blogControl.Visibility               = Visibility.Hidden;
            helpControl.Visibility               = Visibility.Hidden;
            theLinksControl.Visibility           = Visibility.Hidden;
            theJobsControl.Visibility            = Visibility.Hidden;
            currentPageTextBlock.Text            = "BLOG POSTS";
            forumControl.Visibility              = Visibility.Hidden;
            theIndividualForumControl.Visibility = Visibility.Hidden;

            if (!BlogLoaded)
            {
                temporaryBlogGrid.Visibility = Visibility.Visible;

                FetchText.Text = "Fetching blog posts for you...";
                try
                {
                    if (InternetChecker.InternetAvailable())
                    {
                        jsonObtainer = new JsonObtainer(BlogEndpoint, "From_BOLKAY_BLOG_SURF");
                        string jsonResult = await jsonObtainer.GetJsonStringAsync();

                        AfricoderBlogFeed africoderBlogFeed = JsonConvert.DeserializeObject <AfricoderBlogFeed>(jsonResult);

                        if (jsonResult != string.Empty)
                        {
                            foreach (var result in africoderBlogFeed.data)
                            {
                                string date = result.created.date;


                                string convertedTime = Convert.ToDateTime(DateTime.Parse(date)).ToString(("ddd, dd MMM yyyy hh:mm:tt"));
                                result.created.date = convertedTime;
                            }

                            foreach (var dat in africoderBlogFeed.data)
                            {
                                dat.LoggedInID = ID;
                            }

                            blogControl.TheLB.ItemsSource = africoderBlogFeed.data;
                        }
                        //display the blog
                        blogControl.Visibility = Visibility.Visible;

                        temporaryBlogGrid.Visibility = Visibility.Hidden;

                        //MessageBox.Show("Done");

                        //Blog has been loaded
                        BlogLoaded = true;
                    }
                    else
                    {
                        FetchText.Text = NetworkFailedMessage;
                    }
                }
                catch
                {
                    string errorResult = await jsonObtainer.GetJsonStringAsync();

                    FetchText.Text = NetworkFailedMessage;
                }
            }
            else
            {
                blogControl.Visibility = Visibility.Visible;
                //MessageBox.Show("Blog has been loaded");
            }
        }