示例#1
0
        public ActionResult ViewPost(int id = 0)
        {
            Post post = pr.GetPost(id, false);

            if (post != null)
            {
                User user = Session["user"] as User;
                if (user != null)
                {
                    if (cr.IsUserFollowing(post.ChannelID, user.UserID))
                    {
                        ViewBag.Follow = "true";
                    }
                    else
                    {
                        ViewBag.Follow = "false";
                    }

                    if (ar.IsAddonThere(post.PostID, user.UserID, 2, false))
                    {
                        ViewBag.Like = "true";
                    }
                    else
                    {
                        ViewBag.Like = "false";
                    }

                    if (ar.IsAddonThere(post.PostID, user.UserID, 4, false))
                    {
                        ViewBag.Dislike = "true";
                    }
                    else
                    {
                        ViewBag.Dislike = "false";
                    }

                    ar.AddClick(id, user.UserID);
                }
                else
                {
                    ar.AddClick(id);
                }

                return(View(post));
            }
            else
            {
                return(RedirectToAction("NotFound", "Home"));
            }
        }
示例#2
0
        public ActionResult ViewChannel(int id = 0)
        {
            Channel ch = cr.GetChannelByID(id, false);

            if (id > 0 && ch != null)
            {
                User current = Session["user"] as User;
                if (current != null && cr.IsUserFollowing(ch.ChannelID, current.UserID))
                {
                    ViewBag.Follow = "true";
                }
                else
                {
                    ViewBag.Follow = "false";
                }

                return(View(cr.GetChannelByID(id, false)));
            }
            else
            {
                return(RedirectToAction("NotFound", "Home"));
            }
        }