//如果需要另外的Service来解决,必须new 对象出来,不然存在一个循环引用的问题,但是还是有好处的,就是避免了创建过多的对象出来 public UserSimp Login(string account, string password) { if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password)) { throw new UserException("密码或者账号为空,请重新输入"); } if (!AccountExist(account)) { throw new UserException("账户不存在,大兄弟!"); } DelFlag status = (DelFlag)Convert.ToInt32(DbSession.UserDal.GetUserStatus(account)); //可能存在异常,我们继续往上抛出 if (status == DelFlag.Deleted) //账户被删除 { throw new UserException("此用户已被删除,请申诉或者重新申请账户"); } if (status == DelFlag.Freeze) { throw new UserException("当前账户被冻结"); } //可以获取用户信息 UserSimp model = null; if (Md5String.GetMd5String(password) == DbSession.UserDal.GetPassword(account).ToString()) { //表示信息校验成功 //出现的异常继续往上抛出 model = DbSession.UserDal.GetUserSimp(account); } else { //密码错误,出现异常了 throw new UserException("用户密码错误"); } return(model); }
public int ChangeFriendRequestState(int friendrequestid, UserLooked lookied, PrResult result, DelFlag delFlag) { string sql = "update user_friendrequest set looked=@looked,result=@result,delflag=@delflag where id=@id"; SqlParameter spm = new SqlParameter("@id", SqlDbType.Int) { Value = friendrequestid }; return(SqlHelper.ExecuteNonquery(sql, CommandType.Text, spm)); }