public ActionResult ResetPassword(ForgetPassword aForgetPassword) { if (Session["ValidUser"] != null) { if (aForgetPassword.LoginId != null && aForgetPassword.Role == "User") { aForgetPassword.NewPassword = Crypto.Hash(aForgetPassword.NewPassword); string message = aHomeManager.ChangeUserPassword(aForgetPassword); if (message == "Success") { Session["ValidUser"] = null; TempData["Message"] = "Hi! Your password has changed successfully. Please Login now!"; return(RedirectToAction("Login", "Register")); } else { ViewBag.ErrorMessage = message; } } if (aForgetPassword.LoginId != null && aForgetPassword.Role == "Doctor") { aForgetPassword.NewPassword = Crypto.Hash(aForgetPassword.NewPassword); string message = aHomeManager.ChangeDoctorPassword(aForgetPassword); if (message == "Success") { Session["ValidUser"] = null; TempData["Message"] = "Hello Doctor! Your password has changed successfully. Please Login now!"; return(RedirectToAction("Login", "Register")); } else { ViewBag.ErrorMessage = message; } } if (aForgetPassword.ContactPersonMobileNo != null) { aForgetPassword.NewPassword = Crypto.Hash(aForgetPassword.NewPassword); string message = aHomeManager.ChangeMedicalPassword(aForgetPassword); if (message == "Success") { Session["ValidUser"] = null; TempData["Message"] = "Your password has changed successfully. Please Login now!"; return(RedirectToAction("Login", "Register")); } else { ViewBag.ErrorMessage = message; } } ViewBag.ErrorMessage = "Something went wrong. Please try again!"; return(View()); } return(RedirectToAction("ForgetPassword", "Register")); }