//add userInfo
        public bool AddUser(UserViewModel modelView, out string error_msg, out int error_code)
        {
            bool returnValue = false;

            error_msg  = "操作失败";
            error_code = (int)ReturnCode.OPERATION_FAILED;
            using (var db = new PeiSongEntities())
            {
                S_User model = new S_User();
                model.UserID     = Guid.NewGuid().ToString("N");
                model.LogCode    = modelView.LoginId;
                model.UserPwd    = Encrypt_Helper_SF.UserMd5(modelView.UserPwd.Trim() + "SF_Frame_app_8");
                model.UserName   = modelView.UserName;
                model.Gender     = modelView.Gender;
                model.UserPhone  = modelView.UserPhone;
                model.RoleID     = "0";// (int)RecordState.NORMAL;
                model.UserState  = (int)UserState.NORMAL;
                model.Creator    = modelView.Creator;
                model.CreateTime = DateTime.Now;
                db.S_User.Add(model);
                if (db.SaveChanges() > 0)
                {
                    error_msg   = "添加成功";
                    error_code  = (int)ReturnCode.OK;
                    returnValue = true;
                }
                return(returnValue);
            }
        }
        public UserInfoSelfViewModel app_UserLogin(string loginID, string secretString, out string Msg, out int Code)
        {
            using (var db = new PeiSongEntities())
            {
                var userInfo = db.P_Person.Single(c => c.PersonID == loginID);
                if (userInfo == null)
                {
                    Msg = "用户不存在";
                }
                string pwd = Encrypt_Helper_SF.UserMd5(secretString.Trim() + "SF_Frame_app_8");
                if (userInfo.PersonPwd != pwd)
                {
                    Msg = "账号或密码错误";
                }
                Msg  = "登录成功";
                Code = (int)ReturnCode.OK;
                UserInfoSelfViewModel model = new UserInfoSelfViewModel();
                model.UserID  = userInfo.PersonID.ToString();
                model.LoginId = userInfo.LogID;
                model.Phone   = userInfo.PersonPhone;
                // model.Address = userInfo.Address;
                model.UserName = userInfo.PersonName;

                return(model);
            }
        }
Beispiel #3
0
        public UserInfoSelfViewModel app_UserLogin(string loginID, string loginPwd, out string error_message, out int error_code)
        {
            using (var db = new PeiSongEntities())
            {
                var userInfo = db.S_User.FirstOrDefault(c => c.LogCode == loginID);
                UserInfoSelfViewModel model = new UserInfoSelfViewModel();
                if (userInfo == null)
                {
                    error_message = "用户不存在"; error_code = -1; return(model);
                }
                string pwd = Encrypt_Helper_SF.UserMd5(loginPwd + "SF_Frame_app_8");
                if (userInfo.UserPwd != pwd)
                {
                    error_message = "账号或密码错误"; error_code = -1; return(model);
                }
                error_message = "登录成功";
                error_code    = (int)ReturnCode.OK;

                model.UserID   = userInfo.UserID.ToString();
                model.LoginId  = userInfo.LogCode;
                model.Phone    = userInfo.UserPhone;
                model.UserName = userInfo.UserName;
                return(model);
            }
        }
 //updatePassWord
 public bool updatePassWord(string uid, string pwd, out string Msg)
 {
     using (var db = new PeiSongEntities())
     {
         Msg = "操作失败";
         var model = db.P_Person.FirstOrDefault(c => c.PersonID.ToString() == uid);
         model.PersonPwd = Encrypt_Helper_SF.UserMd5(pwd + "SF_Frame_app_8");
         bool re = db.SaveChanges() > 0;
         if (re)
         {
             Msg = "修改成功";
         }
         return(re);
     }
 }