public ActionResult ChangePassword(Models.User oUser) { if (ModelState.IsValid) { if (!oUser.Password.Equals(oUser.ConfirmPassword, StringComparison.CurrentCultureIgnoreCase)) { Int32 nOutput = oUser.ChangePassword(oUser.User_ID, oUser.Password, oUser.ConfirmPassword); switch (nOutput) { case 1: ViewBag.Message = "Password changed successfully"; break; case -1: ViewBag.Message = "User is not valid."; break; case -2: ViewBag.Message = "Error occurred while changing password."; break; } } else { ModelState.AddModelError("", "New password not be same as current password"); } //if (oUser.CheckValidPassword(oUser.User_ID,oUser.Password)) //{ //} //else //{ // ModelState.AddModelError("", "Current password does not match with our record. Please enter correct password"); //} } return(View()); }