// // GET: /news/ //---------------------------------------------------------------------------------------------------------- // cache applied to data select (here need to show random articles) public ActionResult GetLatestNews() { hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); List <hypster_tv_DAL.newsPost> news_list = new List <hypster_tv_DAL.newsPost>(); news_list = newsManager.GetLatestNews_cache(40); List <hypster_tv_DAL.newsPost> news_list_Display = new List <hypster_tv_DAL.newsPost>(); int maxPostsNum = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["numberOfPosts_HomePage"]); if (news_list.Count > maxPostsNum) { Random randomGen = new Random(); do { int next_article = randomGen.Next(0, news_list.Count); hypster_tv_DAL.newsPost item = new hypster_tv_DAL.newsPost(); item = news_list[next_article]; if (!news_list_Display.Contains(item)) { news_list_Display.Add(item); } } while (news_list_Display.Count < maxPostsNum); } return(View(news_list_Display)); }
public ActionResult SpecificMedia() { hypster_tv.ViewModels.HomePageViewModel model = new hypster_tv.ViewModels.HomePageViewModel(); ViewBag.CurrPage_Start = 0; ViewBag.CurrPage_End = POSTS_NUM_PAGING; hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); model.posts_list = newsManager.GetLatestNews_cache(); model.NumOfPosts = model.posts_list.Count; double tmp_numPages = (double)model.NumOfPosts / (double)POSTS_NUM_PAGING; if ((tmp_numPages - (int)tmp_numPages) > 0) { tmp_numPages++; } model.NumOfPages = (int)tmp_numPages; return(View(model)); }
public ActionResult Index() { return(RedirectPermanent("http://hypster.com/breaking")); hypster_tv.ViewModels.HomePageViewModel model = new hypster_tv.ViewModels.HomePageViewModel(); ViewBag.CurrPage_Start = 0; ViewBag.CurrPage_End = POSTS_NUM_PAGING; hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); model.posts_list = newsManager.GetLatestNews_cache(); model.NumOfPosts = model.posts_list.Count; double tmp_numPages = (double)model.NumOfPosts / (double)POSTS_NUM_PAGING; if ((tmp_numPages - (int)tmp_numPages) > 0) { tmp_numPages++; } model.NumOfPages = (int)tmp_numPages; return(View(model)); }
/// <summary> /// Redirect to display Next Post /// </summary> /// <returns></returns> public ActionResult nextPost() { if (Request.QueryString["PID"] != null) { int post_ID = 0; if (!Int32.TryParse(Request.QueryString["PID"], out post_ID)) { post_ID = 0; } if (post_ID != 0) { hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); List <hypster_tv_DAL.newsPost> posts_list = new List <hypster_tv_DAL.newsPost>(); posts_list = newsManager.GetLatestNews_cache(); for (int i = 0; i < posts_list.Count - 1; i++) { if (posts_list[i].post_id == post_ID) { return(RedirectToAction("getPost", "post", new { post_guid = posts_list[i + 1].post_guid })); } } } } //return to news home if no next post return(RedirectToAction("Index", "home")); }
public ActionResult Featured() { return(RedirectPermanent("http://hypster.com/breaking")); hypster_tv.ViewModels.HomePageViewModel model = new hypster_tv.ViewModels.HomePageViewModel(); ViewBag.CurrPage_Start = 0; ViewBag.CurrPage_End = POSTS_NUM_PAGING; hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); model.posts_list = newsManager.GetLatestNews_cache(); return(View(model)); }
public ActionResult GetLatestNews() { // 1.general declarations //----------------------------------------------------------------------------------------------------- hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement(); //----------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------- List <hypster_tv_DAL.newsPost> news_list = new List <hypster_tv_DAL.newsPost>(); List <hypster_tv_DAL.newsPost> news_list_Display = new List <hypster_tv_DAL.newsPost>(); news_list = newsManager.GetLatestNews_cache(30); //num of posts int maxPostsNum = 6; //num of posts if (news_list.Count > maxPostsNum) { Random randomGen = new Random(); do { int next_article = randomGen.Next(0, news_list.Count); hypster_tv_DAL.newsPost item = new hypster_tv_DAL.newsPost(); item = news_list[next_article]; if (!news_list_Display.Contains(item)) { news_list_Display.Add(item); } } while (news_list_Display.Count < maxPostsNum); } //----------------------------------------------------------------------------------------------------- return(View(news_list_Display)); }