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 })); } }
/// <summary> /// 加载时是否赞过 /// </summary> /// <param name="logid"></param> /// <returns>0赞过、1未赞</returns> public int ifZan(int id) { int value = 0; ViewtZanModels zan = zanclient.GetByFromToUid(id, user.Uid, 2); if (zan != null) { value = 1; } return(value); }
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 })); } }