Exemplo n.º 1
0
        public JsonResult LikeNews()
        {
            string mess  = "";
            bool   check = false;

            var like = dao.CheckLike(WebYoutube.Session.User.Id, NewsID);
            var dis  = dao.CheckDislike(WebYoutube.Session.User.Id, NewsID);

            if (like == false && dis == false)
            {
                mess = dao.InsertLikeNews(WebYoutube.Session.User.Id, NewsID);
            }
            else if (like == true && dis == false)
            {
                mess = dao.DeleteLike(WebYoutube.Session.User.Id, NewsID);
            }
            else if (like == false && dis == true)
            {
                mess = dao.InsertLikeNews(WebYoutube.Session.User.Id, NewsID);
                mess = dao.DeleteDislike(WebYoutube.Session.User.Id, NewsID);
            }

            if (mess == "")
            {
                check = true;
            }
            else
            {
                check = false;
            }

            return(Json(new
            {
                Status = check,
                Mess = mess
            }, JsonRequestBehavior.AllowGet));
        }