public bool DeleteForgetPasswordRequest(ForgetPasswordRequest forgetPasswordRequest) { if (forgetPasswordRequest == null) return false; _unitOfWork.ForgetPasswordRequestRepository.Delete(forgetPasswordRequest); _unitOfWork.Save(); return true; }
public bool EditForgetPasswordRequest(ForgetPasswordRequest forgetPasswordRequest) { _unitOfWork.ForgetPasswordRequestRepository.Edit(forgetPasswordRequest); _unitOfWork.Save(); return true; }
public ActionResult ForgetPasswordRequest(ForgetPasswordRequestModel model) { if (ModelState.IsValid) { var user = _userAccountService.GetUserDetail(model.UserName); if (user != null) { var forgetPasswordRequest = new ForgetPasswordRequest() { Completed = false, ExpieryDate = DateTime.Now.AddMonths(2), GeneratedDate = DateTime.Now, RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()), UserProfileID = user.UserProfileID //RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()), //UserAccountID = user.UserAccountId }; if (_forgetPasswordRequestService.AddForgetPasswordRequest(forgetPasswordRequest)) { string to = user.Email; string subject = "Password Change Request"; string link = "localhost:" + Request.Url.Port + "/Account/ForgetPassword/?key=" + forgetPasswordRequest.RequestKey; string body = string.Format(@"Dear {1} <br /><br /> A password reset request has been submitted for your Email account. If you submitted this password reset request, please follow the following link. <br /><br /> <a href='{0}'>Please Follow this Link</a> <br /> <br /><br /> Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours. <br /><br /> Thank you,<br /> Administrator. ", link, user.UserName); try { // Read the configuration table for smtp settings. string from = _settingService.GetSettingValue("SMTP_EMAIL_FROM"); string smtp = _settingService.GetSettingValue("SMTP_ADDRESS"); int port = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT")); string userName = _settingService.GetSettingValue("SMTP_USER_NAME"); string password = _settingService.GetSettingValue("SMTP_PASSWORD"); // send the email using the utilty method in the shared dll. Cats.Helpers.SendMail mail = new Helpers.SendMail(from, to, subject, body, null, true, smtp, userName, password, port); ModelState.AddModelError("Sucess", "Email has Sent to your email Address."); //return RedirectToAction("ConfirmPasswordChange"); } catch (Exception e) { ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again."; } } ModelState.AddModelError("Sucess", "Email has Sent to your email Address."); } // ModelState.AddModelError("Errors", "Invalid User Name " + model.UserName); } return View(); }