public static List <LatestPostFeeds> GetLatestPostFeeds()
        {
            string jsonRSS = "";

            using (WebClient wc = new WebClient())
            {
                jsonRSS = wc.DownloadString("https://talk.manvfat.com/c/sweating/mvf-football.json");
            }

            List <LatestPostFeeds> feeds = new List <LatestPostFeeds>();

            var model = JsonConvert.DeserializeObject <RootObject>(jsonRSS);

            foreach (var item in model.topic_list.topics)
            {
                var user = (from u in model.users
                            join p in item.posters on u.id equals p.user_id
                            select new User
                {
                    id = u.id,
                    username = u.username.Replace("_", " "),
                    avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
                }).ToList();

                LatestPostFeeds feed = new LatestPostFeeds()
                {
                    Title            = item.title,
                    ShortDescription = item.excerpt,
                    Link             = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
                    Tag = item.tags != null?item.tags.FirstOrDefault() : null,
                              TagLink = item.tags != null ? "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault() : null,
                              users   = user
                };

                feeds.Add(feed);
            }

            return(feeds.Take(10).ToList());
        }
        public static List <LatestPostFeeds> GetLeagueNewsFeed(Controller ctrl)
        {
            List <LatestPostFeeds> Final_Feeds = new List <LatestPostFeeds>();

            List <LatestPostFeeds> Global_Feeds = new List <LatestPostFeeds>();
            List <LatestPostFeeds> League_Feeds = new List <LatestPostFeeds>();

            //if (ctrl.Session["Fixture_LeagueID"] != null)
            //{
            //    long LeagueID = Convert.ToInt64(ctrl.Session["Fixture_LeagueID"]);
            //    LeaguesRepository leagueRepo = new LeaguesRepository();
            //    var league = leagueRepo.ReadOne(LeagueID);
            //    if (!string.IsNullOrEmpty(league.NewsTag))
            //    {
            //        string jsonRSS = "";
            //        try
            //        {
            //            using (WebClient wc = new WebClient())
            //            {
            //                jsonRSS = wc.DownloadString("https://talk.manvfat.com/tags/" + league.NewsTag + ".json");
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            //404 Not Found error Occurred, when a tag is entered in Leagues maintenance screen but it is not available on https://talk.manvfat.com/tags/ server
            //            SecurityUtils.AddAuditLog("RSS Feed", "RSS Feed 404 Not Found error Occurred for League: " + league.LeagueName + " NewsTag: " + league.NewsTag + " Not Available");
            //            // ErrorHandling.HandleException(ex);
            //            //  return League_Feeds;
            //        }

            //        if (!string.IsNullOrEmpty(jsonRSS))
            //        {
            //            var model = JsonConvert.DeserializeObject<RootObject>(jsonRSS);

            //            foreach (var item in model.topic_list.topics)
            //            {
            //                var user = (from u in model.users
            //                            join p in item.posters on u.id equals p.user_id
            //                            select new User
            //                            {
            //                                id = u.id,
            //                                username = u.username.Replace("_", " "),
            //                                avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
            //                            }).ToList();

            //                LatestPostFeeds feed = new LatestPostFeeds()
            //                {
            //                    Title = SecurityUtils.TrimText(item.title,62),
            //                    PublishDate = item.created_at,
            //                    LastUpdatedDate = item.bumped_at,
            //                    ShortDescription = item.excerpt,
            //                    Link = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
            //                    Tag = item.tags.FirstOrDefault(),
            //                    TagLink = "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault(),
            //                    users = user
            //                };

            //                feed.Title = SetMinimumLengthOfTitle(feed.Title);

            //                League_Feeds.Add(feed);
            //            }
            //        }
            //    }
            //}

            //Global Feeds
            {
                string jsonRSS = "";
                try
                {
                    using (WebClient wc = new WebClient())
                    {
                        jsonRSS = wc.DownloadString("https://talk.manvfat.com/tags/global.json");
                    }
                }
                catch (Exception ex)
                {
                    //404 Not Found error Occurred, when a tag is entered in Leagues maintenance screen but it is not available on https://talk.manvfat.com/tags/ server
                    SecurityUtils.AddAuditLog("RSS Feed", "RSS Feed 404 Not Found error Occurred for Global Feeds Not Available");
                    // ErrorHandling.HandleException(ex);
                    // return League_Feeds;
                }

                if (!string.IsNullOrEmpty(jsonRSS))
                {
                    var model = JsonConvert.DeserializeObject <RootObject>(jsonRSS);

                    foreach (var item in model.topic_list.topics)
                    {
                        var user = (from u in model.users
                                    join p in item.posters on u.id equals p.user_id
                                    select new User
                        {
                            id = u.id,
                            username = u.username.Replace("_", " "),
                            avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
                        }).ToList();

                        LatestPostFeeds feed = new LatestPostFeeds()
                        {
                            Title            = SecurityUtils.TrimText(item.title, 62),
                            PublishDate      = item.created_at,
                            LastUpdatedDate  = item.bumped_at,
                            ShortDescription = item.excerpt,
                            Link             = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
                            Tag     = item.tags.FirstOrDefault(),
                            TagLink = "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault(),
                            users   = user
                        };

                        feed.Title = SetMinimumLengthOfTitle(feed.Title);

                        Global_Feeds.Add(feed);
                    }
                }
            }

            //Now Fill the Final Feeds
            //We Need to Display 8 feeds in total, if we have 2 Global then we need to pick only 6 from League Feeds to make it 8 feeds in total
            {
                int TotalFinalFeedsRequired = 8;

                //Take onlly 8 Global Feeds
                Global_Feeds = Global_Feeds.OrderByDescending(m => m.LastUpdatedDate).Take(4).ToList();

                var TotalNumOfGlobal_Feeds = Global_Feeds.Count();


                //Take only Feeds minus Global League
                League_Feeds = League_Feeds.OrderByDescending(m => m.LastUpdatedDate).Take(TotalFinalFeedsRequired - TotalNumOfGlobal_Feeds).ToList();

                Final_Feeds.AddRange(Global_Feeds);

                Final_Feeds.AddRange(League_Feeds);
            }


            return(Final_Feeds.OrderByDescending(m => m.LastUpdatedDate).ToList());
        }
        /// <summary>
        ///   2 latest posts tagged from that location (e.g. "Manchester")  https://talk.manvfat.com/tags/manchester.json
        ///   2 latest posts tagged from "global"
        ///   1 hottest topic posts https://talk.manvfat.com/top/weekly.json
        /// </summary>
        /// <param name="PlayerID"></param>
        /// <returns></returns>
        public static List <LatestPostFeeds> GetProgresDashboardFeeds(long PlayerID)
        {
            List <LatestPostFeeds> Final_Feeds = new List <LatestPostFeeds>();

            List <LatestPostFeeds> Global_Feeds = new List <LatestPostFeeds>();
            List <LatestPostFeeds> League_Feeds = new List <LatestPostFeeds>();
            List <LatestPostFeeds> Weekly_Feeds = new List <LatestPostFeeds>();



            //GEt Player League

            #region League News Tag Posts
            //LeaguesRepository leagueRepo = new LeaguesRepository();
            //var SelectedLeague = leagueRepo.GetPlayerSelectedLeague(PlayerID);

            //if (SelectedLeague.LeagueID.HasValue)
            //{
            //    long LeagueID = SelectedLeague.LeagueID.Value;

            //    var league = leagueRepo.ReadOne(LeagueID);
            //    if (!string.IsNullOrEmpty(league.NewsTag))
            //    {
            //        string jsonRSS = "";
            //        try
            //        {
            //            using (WebClient wc = new WebClient())
            //            {
            //                jsonRSS = wc.DownloadString("https://talk.manvfat.com/tags/" + league.NewsTag + ".json");
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            //404 Not Found error Occurred, when a tag is entered in Leagues maintenance screen but it is not available on https://talk.manvfat.com/tags/ server
            //            SecurityUtils.AddAuditLog("RSS Feed", "RSS Feed 404 Not Found error Occurred for League: " + league.LeagueName + " NewsTag: " + league.NewsTag + " Not Available");
            //            // ErrorHandling.HandleException(ex);
            //            //  return League_Feeds;
            //        }

            //        if (!string.IsNullOrEmpty(jsonRSS))
            //        {
            //            var model = JsonConvert.DeserializeObject<RootObject>(jsonRSS);

            //            foreach (var item in model.topic_list.topics)
            //            {
            //                var user = (from u in model.users
            //                            join p in item.posters on u.id equals p.user_id
            //                            select new User
            //                            {
            //                                id = u.id,
            //                                username = u.username.Replace("_", " "),
            //                                avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
            //                            }).ToList();

            //                LatestPostFeeds feed = new LatestPostFeeds()
            //                {
            //                    Title = item.title,
            //                    PublishDate = item.created_at,
            //                    LastUpdatedDate = item.bumped_at,
            //                    ShortDescription = item.excerpt,
            //                    Link = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
            //                    Tag = item.tags.FirstOrDefault(),
            //                    TagLink = "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault(),
            //                    users = user
            //                };

            //               // feed.Title = SetMinimumLengthOfTitle(feed.Title);

            //                League_Feeds.Add(feed);
            //            }
            //        }
            //    }
            //}
            #endregion

            #region Global Posts
            {
                string jsonRSS = "";
                try
                {
                    using (WebClient wc = new WebClient())
                    {
                        jsonRSS = wc.DownloadString("https://talk.manvfat.com/tags/global.json");
                    }
                }
                catch (Exception ex)
                {
                    //404 Not Found error Occurred, when a tag is entered in Leagues maintenance screen but it is not available on https://talk.manvfat.com/tags/ server
                    SecurityUtils.AddAuditLog("RSS Feed", "RSS Feed 404 Not Found error Occurred for Global Feeds Not Available");
                    // ErrorHandling.HandleException(ex);
                    // return League_Feeds;
                }

                if (!string.IsNullOrEmpty(jsonRSS))
                {
                    var model = JsonConvert.DeserializeObject <RootObject>(jsonRSS);

                    foreach (var item in model.topic_list.topics)
                    {
                        var user = (from u in model.users
                                    join p in item.posters on u.id equals p.user_id
                                    select new User
                        {
                            id = u.id,
                            username = u.username.Replace("_", " "),
                            avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
                        }).ToList();

                        LatestPostFeeds feed = new LatestPostFeeds()
                        {
                            Title            = item.title,
                            PublishDate      = item.created_at,
                            LastUpdatedDate  = item.bumped_at,
                            ShortDescription = item.excerpt,
                            Link             = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
                            Tag     = item.tags.FirstOrDefault(),
                            TagLink = "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault(),
                            users   = user
                        };

                        //feed.Title = SetMinimumLengthOfTitle(feed.Title);

                        Global_Feeds.Add(feed);
                    }
                }
            }

            #endregion

            #region Weekly Posts
            {
                string jsonRSS = "";
                try
                {
                    using (WebClient wc = new WebClient())
                    {
                        jsonRSS = wc.DownloadString("https://talk.manvfat.com/top/weekly.json");
                    }
                }
                catch (Exception ex)
                {
                    //404 Not Found error Occurred, when a tag is entered in Leagues maintenance screen but it is not available on https://talk.manvfat.com/tags/ server
                    SecurityUtils.AddAuditLog("RSS Feed", "RSS Feed 404 Not Found error Occurred for Global Feeds Not Available");
                    // ErrorHandling.HandleException(ex);
                    // return League_Feeds;
                }

                if (!string.IsNullOrEmpty(jsonRSS))
                {
                    var model = JsonConvert.DeserializeObject <RootObject>(jsonRSS);

                    foreach (var item in model.topic_list.topics)
                    {
                        var user = (from u in model.users
                                    join p in item.posters on u.id equals p.user_id
                                    select new User
                        {
                            id = u.id,
                            username = u.username.Replace("_", " "),
                            avatar_template = "https://talk.manvfat.com" + u.avatar_template.Replace("{size}", "100")
                        }).ToList();

                        LatestPostFeeds feed = new LatestPostFeeds()
                        {
                            Title            = item.title,
                            PublishDate      = item.created_at,
                            LastUpdatedDate  = item.bumped_at,
                            ShortDescription = item.excerpt,
                            Link             = "https://talk.manvfat.com" + "/t/" + item.slug + "/" + item.id,
                            Tag     = item.tags.FirstOrDefault(),
                            TagLink = "https://talk.manvfat.com/tags/" + item.tags.FirstOrDefault(),
                            users   = user
                        };

                        // feed.Title = SetMinimumLengthOfTitle(feed.Title);

                        Weekly_Feeds.Add(feed);
                    }
                }
            }

            #endregion


            //Get 2 latest posts tagged from that location (e.g. "Manchester")  https://talk.manvfat.com/tags/manchester.json
            League_Feeds = League_Feeds.OrderByDescending(m => m.LastUpdatedDate).Take(2).ToList();
            Global_Feeds = Global_Feeds.OrderByDescending(m => m.LastUpdatedDate).Take(2).ToList();
            Weekly_Feeds = Weekly_Feeds.OrderByDescending(m => m.LastUpdatedDate).Take(1).ToList();

            Final_Feeds.AddRange(League_Feeds);
            Final_Feeds.AddRange(Global_Feeds);
            Final_Feeds.AddRange(Weekly_Feeds);

            return(Final_Feeds.OrderByDescending(m => m.LastUpdatedDate).ToList());
        }