public UserDTO GetUserByEmail(string userEmail) { User user = userProfile.GetUserByEmail(userEmail); return(user != null ? converterToDTO.ConvertToUserDTO(user) : throw new ArgumentNullException()); }
public ActionResult ForgotPassword(AccountModels.ForgotPass ForgotPass) { if (ModelState.IsValid) { UserProfileService = new UserProfileServices(new DealsDB()); var checkemail = UserProfileService.GetUserByEmail(ForgotPass.ForgotPassEmail); if (checkemail != null) { Guid guid = Guid.NewGuid(); UserVerification ForgotPasswordUser = new UserVerification() { Purpose = "ResetPass", Userid = checkemail.UserId, UserVerificationCode = guid, AddedOn = System.DateTime.Now.Date }; UserVerificationService.Insert(ForgotPasswordUser); string body = string.Empty; //using streamreader for reading my htmltemplate using (StreamReader reader = new StreamReader(@"~/EmailTemp/ResetPasswordTemplate.html")) { body = reader.ReadToEnd(); } string URL = Domain + "/Register_Login/Reset/" + ForgotPasswordUser.UserVerificationCode; body = body.Replace("{LinkUrl}", URL); //replacing the required things UserProfileService.UserMail(body, "For Reset Password", checkemail.Email); ViewBag.ForgotPassError = "Check Your Mail for Reset Link"; return(View()); } ViewBag.ForgotPassError = "EmailId Does not Exists"; } return(View(ForgotPass)); }