Beispiel #1
0
 public ActionResult TopicDetail(int id)
 {
     ViewBag.support = "nosupport";
     if (null != CurrentUser)
     {
         HttpCookie cookie = Request.Cookies["topicFav_" + id + CurrentUser.UserID];
         if (null != cookie) //取消赞
         {
             ViewBag.support = "support";
         }
     }
     YSWL.MALL.Model.SNS.GroupTopics topicsModel = bllTopic.GetModelByCache(id);
     return(View(topicsModel));
 }
Beispiel #2
0
 /// <summary>
 /// 操作GroupTopics 赞或者取消赞
 /// </summary>
 /// <param name="topic">话题</param>
 /// <param name="type">操作1代表赞0代表取消赞</param>
 /// <returns></returns>
 public bool OperateTopic(YSWL.MALL.Model.SNS.GroupTopics topic, int type)
 {
     if (topic == null)
     {
         return(false);
     }
     if (type == 1)
     {
         topic.FavCount += 1;
         return(bllTopic.Update(topic));
     }
     else if (type == 0)
     {
         topic.FavCount -= 1;
         return(bllTopic.Update(topic));
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
        public ActionResult AddTopicFav(int topicId)
        {
            JsonObject jsonObject = new JsonObject();

            if (null == currentUser)
            {
                jsonObject.Accumulate("result", "3");//3表示没有登录
                return(base.Json(jsonObject));
            }
            YSWL.MALL.Model.SNS.GroupTopics topicsModel = bllTopic.GetModelByCache(topicId);
            HttpCookie cookie = Request.Cookies["topicFav_" + topicId + CurrentUser.UserID];

            if (null != cookie)//取消赞
            {
                cookie         = new HttpCookie("topicFav_" + topicId + CurrentUser.UserID);
                cookie.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(cookie);
                if (!OperateTopic(topicsModel, 0))
                {
                    jsonObject.Accumulate("result", "0");//失败了
                    return(base.Json(jsonObject));
                }
            }
            else//赞
            {
                cookie = new HttpCookie("topicFav_" + topicId + CurrentUser.UserID);
                Response.Cookies.Add(cookie);
                if (!OperateTopic(topicsModel, 1))
                {
                    jsonObject.Accumulate("result", "0");//失败了
                    return(base.Json(jsonObject));
                }
                cookie.Value = "HasSupport";
            }
            int count = topicsModel.FavCount;

            jsonObject.Accumulate("totalCount", count);
            jsonObject.Accumulate("result", "1");//1代表成功
            return(base.Json(jsonObject));
        }