public string ResetPassword(GetResetPasswordViewModel model) { if (!string.IsNullOrEmpty(model.NewPassword)) { using (var context = new NCContext.NCContext()) { var user = context.Students.Where(a => a.ResetPasswordCode == model.Resetpasswordcode).FirstOrDefault(); if (user != null) { var u = context.Users.Where(x => x.Email == user.Email).FirstOrDefault(); u.Password = model.NewPassword; user.Password = model.NewPassword; user.ResetPasswordCode = ""; context.SaveChanges(); return("true"); } } return("Something wrong happned"); } return("Something wrong happned"); }
public ActionResult ResetPassword(string id) { if (string.IsNullOrEmpty(id)) { return(HttpNotFound()); } using (var context = new NCContext.NCContext()) { var validuser = context.Students.Where(x => x.ResetPasswordCode == id).FirstOrDefault(); if (validuser != null) { GetResetPasswordViewModel model = new GetResetPasswordViewModel(); model.Resetpasswordcode = id; model.NewPassword = validuser.Password; return(View(model)); } else { return(HttpNotFound()); } } }