Exemple #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"));
            }
        }
Exemple #2
0
        public int DislikePost(int postID)
        {
            User      current      = Session["user"] as User;
            AddonRepo ar           = new AddonRepo();
            int       dislikeCount = ar.AddDislike(postID, current.UserID);

            if (dislikeCount == 0)
            {
                dislikeCount = ar.SetAddonState(postID, current.UserID, 4, false);
            }

            if (ar.IsAddonThere(postID, current.UserID, 2) && ar.IsAddonThere(postID, current.UserID, 2, false))
            {
                ar.SetAddonState(postID, current.UserID, 2, true);
            }

            return(dislikeCount);
        }