/// <summary> /// 通过用户名得到用户Id,返回用户Id /// </summary> /// <param name="userName"></param> /// <returns></returns> public int GainUserId(string userName) { User_dal user = new User_dal(); int userId = (int)user.GetUserId(userName); return(userId); }
/// <summary> /// 通过用户名查询该用户的ID, /// 成功返回1 /// 失败返回0 /// </summary> /// <param name="userName"></param> /// <returns></returns> public int GetUserId(string userName) { User_dal user_dal = new User_dal(); object userId = user_dal.GetUserId(userName); if (userId == null || userId == System.DBNull.Value) { return(0); } return((int)userId); }
/// <summary> /// 执行关注,取消关注或不执行操作的逻辑判断 /// 执行操作返回1,无操作返回0 /// </summary> /// <param name="concernName"></param> /// <param name="beConcernName"></param> /// <param name="Num"></param> /// <returns></returns> public int LgGuanZhuUser(string concernName, string beConcernName, string Num) { User_dal user_dal = new User_dal(); int concernNameId = Convert.ToInt32(user_dal.GetUserId(concernName)); int beConcernNameId = Convert.ToInt32(user_dal.GetUserId(beConcernName)); object exist = user_dal.select_ConIdAndBeConId(concernNameId, beConcernNameId); //查询记录是否存在,null或concernNameId if (exist == null && Num == "1") //无关注记录,只可插入不可删除 { return(user_dal.insert_IdTotb_Attention(concernNameId, beConcernNameId)); } else if (exist != null && Num == "0")//有关注记录,只可删除不可插入 { return(user_dal.delete_IdFromtb_Attention(concernNameId, beConcernNameId)); } else { return(0); } }