Esempio n. 1
0
        public JsonResult ChangePw(IFormCollection collection)
        {
            var entity = new ChangePwViewModel();

            TryUpdateModelAsync(entity);

            if (string.IsNullOrWhiteSpace(entity.OldPw) || string.IsNullOrWhiteSpace(entity.NewPw))
            {
                return(Json("原密码和新密码不能为空"));
            }
            entity.Id = AppUser.Id;
            var service = new AppUserService();
            var result  = service.ChangePw(entity.Id, entity.OldPw, entity.NewPw);

            return(Json(result));
        }
Esempio n. 2
0
 public JsonResult ChangePw(ChangePwViewModel model)
 {
     if (ModelState.IsValid)
     {
         var service = new UserService();
         var result  = service.ChangePw(AppUser.Id, model.OldPw, model.NewPw);
         return(Json(result));
     }
     else
     {
         var errorMessage = "";
         foreach (var v in ModelState.Values)
         {
             foreach (var e in v.Errors)
             {
                 errorMessage += e.ErrorMessage + ";";
             }
         }
         return(Json(ResultUtil.Do(ResultCodes.验证失败, errorMessage)));
     }
 }