public JsonResult iZan()
        {
            try
            {
                ViewtZanModels zanEntity = new ViewtZanModels();

                int Uid     = Convert.ToInt32(Request.Form["uid"]);//主键ID
                int iToType = Convert.ToInt32(Request.Form["UserType"]);
                zanEntity = zanclient.GetExists(user.Uid, Uid, user.UserType.Value, iToType);
                if (zanEntity == null)
                {
                    zanEntity            = new ViewtZanModels();
                    zanEntity.iToUid     = Uid;      //被赞人
                    zanEntity.iFromUid   = user.Uid; //登录人
                    zanEntity.iType      = user.UserType;
                    zanEntity.iToType    = iToType;
                    zanEntity.CreateDate = DateTime.Now;
                    zanEntity.loginType  = 0;
                    zanclient.Add(zanEntity);
                    return(Json(new { code = 0 }));
                }
                else
                {
                    return(Json(new { code = 2 }));//已经赞过
                }
            }
            catch (Exception ex)
            {
                return(Json(new { code = 1 }));
            }
        }
Beispiel #2
0
 public ActionResult Create(int?id)
 {
     try
     {
         int            resultcode = 0;
         int            Uid        = Convert.ToInt32(Request.Form["uid"]);//专页的导师id
         ViewtZanModels model      = client.GetByFromToUid(Uid, user.Uid, 1);
         if (model == null)
         {
             model            = new ViewtZanModels();
             model.iToUid     = Uid;
             model.iFromUid   = user.Uid;//登录者id
             model.CreateDate = DateTime.Now;
             model.iType      = user.UserType;
             resultcode       = client.Add(model);
         }
         else
         {
             return(Json(new { code = 2 }));//已经点过赞的
         }
         return(Json(new { code = resultcode }));
     }
     catch
     {
         return(Json(new { code = 1 }));
     }
 }
        public JsonResult iZanHand(int id)
        {
            try
            {
                int            iCount    = 0;
                ViewtZanModels zanEntity = new ViewtZanModels();
                using (tZanModelsServiceClient zanclient = new tZanModelsServiceClient())
                {
                    zanEntity = zanclient.GetByFromToUid(id, user.Uid, 2);
                    if (zanEntity == null)
                    {
                        zanEntity            = new ViewtZanModels();
                        zanEntity.iFromUid   = user.Uid;
                        zanEntity.iToUid     = id;
                        zanEntity.iType      = user.UserType;
                        zanEntity.iToType    = 2;
                        zanEntity.CreateDate = DateTime.Now;
                        zanEntity.loginType  = 0;
                        zanclient.Add(zanEntity);

                        //查询Count

                        ViewtLearing model = client.GetById(id);
                        iCount         = zanclient.Count(id, user.Uid, 2);
                        model.iZanNums = iCount;
                        client.Update(model);//推荐(赞)量+1
                    }
                    else
                    {
                        return(Json(new { code = 2 }));
                    }
                }

                return(Json(new { code = 0, iCount = iCount }));
            }
            catch (Exception ex)
            {
                return(Json(new { code = 1 }));
            }
        }