public void AddFav(int docId) { try { UserService us = Context.GetService<UserService>(); U_UserInfo u = base.GetUser(); if (u == null) { RenderText("0"); } else { IList<MFavorite> fList = us.MFavoriteBll.GetList(docId); if (fList == null || fList.Count == 0) { MFavorite fav = new MFavorite() { UserId = u.UserId, DocId = docId, CreateTime = DateTime.Now, FavCateId = 0 }; us.MFavoriteBll.Insert(fav); us.DocInfoBll.UpdateFavCount(docId); RenderText("1"); } else { RenderText("2"); } } } catch (Exception ex) { Utils.Log4Net.Error(ex); RenderText("-1"); } }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(MFavorite obj) { return dal.Update(obj); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(MFavorite obj) { return dal.Insert(obj); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(MFavorite obj) { if (obj == null) throw new ArgumentNullException("obj"); String stmtId = "MFavorite.Insert"; return SqlMapper.Instance().QueryForObject<int>(stmtId, obj); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(MFavorite obj) { if (obj == null) throw new ArgumentNullException("obj"); String stmtId = "MFavorite.Update"; int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj); return result > 0 ? true : false; }