public ActionResult ChangePass(int id, string pass) { ChangePW c = new ChangePW(); c.Id = id; return(View(c)); }
public ActionResult ChangePW(ChangePW changePW) { int userId = int.Parse(User.Identity.Name); TbUser user = db.TbUsers.Find(userId); if (!user.Password.Equals(MySecurity.EncryptPassword(changePW.oldPassword))) { return(Json("Old password is incorrect, please enter again!")); } user.Password = MySecurity.EncryptPassword(changePW.newPassword); db.SaveChanges(); return(Json("Password has changed!")); }
public ActionResult ChangePass(ChangePW cp) { int id = cp.Id; var BenhNhan = db.BENHNHANs.Where(s => s.MaBenhNhan == id).FirstOrDefault(); if (BenhNhan.MatKhau == cp.PasswordOld) { BenhNhan.MatKhau = cp.PasswordNew; BenhNhan.Confirmpwd = BenhNhan.MatKhau; db.Entry(BenhNhan).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("passwordOld", "Vui lòng kiểm tra mật khẩu"); return(View(cp)); } }