public IActionResult ChangePassword(ChangePasswordViewModel passwords) { if (HttpContext.Session.GetString("LoginID") == null) { return(View("Login")); } string CurrentPassword = passwords.CurrentPassword; string NewPassword = passwords.NewPassword; passwords.UserID = Convert.ToInt32(HttpContext.Session.GetString("LoginID")); if (ModelState.IsValid) { User userChanged = _context.GetUser(passwords.UserID); if (_context.ChangePassword(CurrentPassword, NewPassword, userChanged)) { TempData["PWMessage"] = "Password change successful!"; _context.LogAction("Password Change", "Password change successful, user has changed their own password.", userChanged); } else { TempData["PWMessage"] = "Current password entered is incorrect, please try again."; _context.LogAction("Password Change", "Password change failure, user entered an invalid password for their account.", userChanged); } } return(View("ChangePassword")); }