public ActionResult Edit(User user) { if (ModelState.IsValid) { var lib = new UserLib(); if (!string.IsNullOrEmpty(user.Password)) { var encryptedMd5Pas = Encryptor.MD5Hash(user.Password); user.Password = encryptedMd5Pas; } var result = lib.Update(user); if (result) { SetAlert("Edit user successfully ", "success"); return(RedirectToAction("Index", "User")); } else { ModelState.AddModelError("", "Update user not successfully"); } } return(View("Index")); }