예제 #1
0
        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));
        }
예제 #2
0
        //
        // 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));
        }
예제 #3
0
        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));
        }
        /// <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"));
        }
예제 #5
0
        public ActionResult getPost(string post_guid)
        {
            return(RedirectPermanent("http://hypster.com/breaking/details/" + post_guid));



            hypster_news.ViewModels.getPostViewModel viewModel = new ViewModels.getPostViewModel();


            hypster_tv_DAL.newsManagement newsManager = new hypster_tv_DAL.newsManagement();

            viewModel.post          = newsManager.GetPostByGUID(post_guid);
            viewModel.comments_list = newsManager.GetPostComments_cache(viewModel.post.post_id);

            return(View(viewModel));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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));
        }
예제 #8
0
 public ActionResult Generate_Hypster_News()
 {
     if (Session["Roles"] != null && Session["Roles"].Equals("Admin"))
     {
         string hyp_sitemap = "";
         hypster_tv_DAL.newsManagement  newsManagement = new hypster_tv_DAL.newsManagement();
         List <hypster_tv_DAL.newsPost> news_posts     = new List <hypster_tv_DAL.newsPost>();
         news_posts = newsManagement.GetAllNews();
         foreach (var item in news_posts)
         {
             string item_str = "";
             item_str    += "<url><loc>http://hypster.com/breaking/details/" + item.post_guid + "</loc><changefreq>weekly</changefreq><priority>1.00</priority></url>" + System.Environment.NewLine;
             hyp_sitemap += item_str;
         }
         ViewBag.SiteMap_STR = hyp_sitemap;
         return(View());
     }
     else
     {
         return(RedirectPermanent("/home/"));
     }
 }
예제 #9
0
        //------------------------------------------------------------------------------------------

        //------------------------------------------------------------------------------------------
        public string addnewtag()
        {
            string ret_res  = "";
            string tag_name = "";

            if (Request.QueryString["tag_name"] != null)
            {
                tag_name = Request.QueryString["tag_name"].ToString();
            }

            int article_id = 0;

            if (Request.QueryString["article_id"] != null)
            {
                Int32.TryParse(Request.QueryString["article_id"], out article_id);
            }

            hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.Member           member        = new hypster_tv_DAL.Member();
            member = memberManager.getMemberByUserName(User.Identity.Name);

            hypster_tv_DAL.newsManagement newsManager  = new hypster_tv_DAL.newsManagement();
            hypster_tv_DAL.newsPost       curr_article = new hypster_tv_DAL.newsPost();
            curr_article = newsManager.GetPostByID(article_id);

            if (curr_article.post_id != 0 && article_id == curr_article.post_id)
            {
                hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement();
                int tag_ID = 0;
                tag_ID = tagManager.AddNewTag(tag_name);
                tagManager.AddTagToNewsArticle(tag_ID, article_id);
                ret_res = tag_ID.ToString() + "|" + article_id.ToString();
            }
            else
            {
                ret_res = "n/a";
            }
            return(ret_res.ToString());
        }