예제 #1
0
파일: Users.cs 프로젝트: mgoogps/carrent
 /// <summary>
 /// 修改用户密码
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public Task <IApiResult> UpdateUserPwd(P_Users.P_UpdatePwd arg)
 {
     return(Task.Run(() =>
     {
         IApiResult ar = new IApiResult();
         try
         {
             using (DAL.CarRentEntities db = new DAL.CarRentEntities())
             {
                 var us = db.Users.Where(u => u.UserID == arg.userid).FirstOrDefault();
                 if (us != null && us.Password == arg.old_userpwd)
                 {
                     us.Password = arg.new_userpwd;
                     db.SaveChanges();
                     ar.message = "success!";
                 }
                 else
                 {
                     ar.code = Interface.StatusCode.parameterError;
                     ar.message = "Old password error";
                 }
             }
         }
         catch (Exception ex)
         {
             Log.Error(this, ex);
             ar.code = Interface.StatusCode.error;
             ar.message = ex.Message;
         }
         return ar;
     }));
 }
예제 #2
0
 public async Task <IApiResult> UpdateUserPwd([FromBody] P_Users.P_UpdatePwd pars)
 {
     return(await ApiAsync(pars, new BLL.UsersManager.Users().UpdateUserPwd));
 }