Exemple #1
0
 private void GetNewsFromNewsList()
 {
     foreach (var favNewsModel in App.Favorites)
     {
         FavoriteNews.Add(
             (NewsPaper.NewsPapers.Find((NewsPaper paper) => paper.PaperTitle == favNewsModel.NewsPaperTitle))
             .NewsList.Find((NewsItem newsItem) => newsItem.GetHashCode() == favNewsModel.HashCode)
             );
     }
 }
Exemple #2
0
 public Task <int> SaveNewsAsync(FavoriteNews news)
 {
     if (news.ID != 0)
     {
         return(_database.UpdateAsync(news));
     }
     else
     {
         return(_database.InsertAsync(news));
     }
 }
Exemple #3
0
        private async void favorite_result(string news_id)
        {
            for (int i = 0; i < Global.news.Count; i++)
            {
                if (news_id == Global.news[i].news_id)
                {
                    tapped_index = i; break;
                }
            }

            var favorite_tapped_news = await App.Favorite_News_Data.GetSelectedNewsAsync(news_id);

            if (favorite_tapped_news == null)
            {
                FavoriteNews favorite_news = new FavoriteNews();

                favorite_news.news_id        = news_id;
                favorite_news.news_image_url = Global.news[tapped_index].news_image_url;
                favorite_news.news_category  = Global.news[tapped_index].news_category;
                favorite_news.news_title     = Global.news[tapped_index].news_title;
                favorite_news.news_date      = Global.news[tapped_index].news_date;
                favorite_news.news_source    = Global.news[tapped_index].news_source;
                favorite_news.writer_name    = Global.news[tapped_index].writer_name;
                favorite_news.writer_image   = Global.news[tapped_index].writer_image;
                favorite_news.writer_profile = Global.news[tapped_index].writer_profile;
                favorite_news.news_url       = Global.news[tapped_index].news_url;
                favorite_news.news_contents  = Global.news[tapped_index].news_contents;

                favorite_news.comment_count          = Global.news[tapped_index].comment_count;
                favorite_news.brief_comment          = Global.news[tapped_index].brief_comment;
                favorite_news.first_commenter_image  = Global.news[tapped_index].first_commenter_image;
                favorite_news.first_commenter_name   = Global.news[tapped_index].first_commenter_name;
                favorite_news.second_commenter_image = Global.news[tapped_index].second_commenter_image;
                favorite_news.second_commenter_name  = Global.news[tapped_index].second_commenter_name;
                favorite_news.third_commenter_image  = Global.news[tapped_index].third_commenter_image;
                favorite_news.third_commenter_name   = Global.news[tapped_index].third_commenter_name;

                await App.Favorite_News_Data.SaveNewsAsync(favorite_news);

                imgFavorite.Source = "favorite.png";
            }
            else
            {
                await App.Favorite_News_Data.DeleteNewsAsync(favorite_tapped_news);

                imgFavorite.Source = "infavorite.png";
            }
        }
Exemple #4
0
        private async void show_favorite_news()
        {
            bool first_favorite = true;
            var  favorite_news  = await App.Favorite_News_Data.GetNewsAsync();


            for (int i = 0; i < favorite_news.Count; i++)
            {
                FavoriteNews tempNews = new FavoriteNews();
                tempNews.news_id = favorite_news[i].news_id;

                if (first_favorite)
                {
                    tempNews.news_image_url_header = favorite_news[i].news_image_url;
                    tempNews.img_header_height     = 200;
                    first_favorite = false;
                }
                else
                {
                    tempNews.news_image_url_contents = favorite_news[i].news_image_url;
                }

                tempNews.news_category  = favorite_news[i].news_category;
                tempNews.news_title     = favorite_news[i].news_title;
                tempNews.news_date      = favorite_news[i].news_date;
                tempNews.news_source    = favorite_news[i].news_source;
                tempNews.writer_name    = favorite_news[i].writer_name;
                tempNews.writer_profile = favorite_news[i].writer_profile;
                tempNews.news_url       = favorite_news[i].news_url;
                tempNews.news_contents  = favorite_news[i].news_contents;

                tempNews.comment_count          = favorite_news[i].comment_count;
                tempNews.brief_comment          = favorite_news[i].brief_comment;
                tempNews.first_commenter_image  = favorite_news[i].first_commenter_image;
                tempNews.first_commenter_name   = favorite_news[i].first_commenter_name;
                tempNews.second_commenter_image = favorite_news[i].second_commenter_image;
                tempNews.second_commenter_name  = favorite_news[i].second_commenter_name;
                tempNews.third_commenter_image  = favorite_news[i].third_commenter_image;
                tempNews.third_commenter_name   = favorite_news[i].third_commenter_name;

                newsInfo.Add(tempNews);
            }

            listview.ItemsSource = newsInfo;
        }
Exemple #5
0
 public Task <int> DeleteNewsAsync(FavoriteNews news)
 {
     return(_database.DeleteAsync(news));
 }