public ActionResult ForgotLoginID(string EmailID) {//verify Email ID string message = ""; // bool status = false; using (Models.LoginDataModel db = new Models.LoginDataModel()) { var account = db.tblTropicalUser.Where(a => a.Email == EmailID).FirstOrDefault(); if (account != null) { //send Email for telling the LoginID //string resetCode = Guid.NewGuid().ToString(); SendForgotIDEmail(account.Email, "ForgotID", account.LoginID); //account.ResetPasswordCode = resetCode; db.Configuration.ValidateOnSaveEnabled = false;//remove reset pw does not match issue db.SaveChanges(); message = "Your LoginID has been sent to your email. Your Login ID is: " + account.LoginID; } else { message = "Account not found"; } } //Generate reset password link ViewBag.Message = message; return(View()); }
public ActionResult ResetPassWord(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (Models.LoginDataModel db = new Models.LoginDataModel()) { var user = db.tblTropicalUser.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "New password updated successfully"; } } } else { message = "Something invalid"; } ViewBag.Message = message; return(View(model)); }