コード例 #1
0
        public void sendLink(String Email)
        {
            try
            {
                //LoanViewModel lvm = new LoanViewModel();
                //String email = lvm.AccountsModel.Email;
                var result = DataReaders.checkEmail(Email);
                WebLog.Log("Email +" + result);
                if (result != null)
                {
                    WebLog.Log("Email +" + result);
                    users.Email = result;
                    WebLog.Log("Email +" + users.Email);
                    users.id = DataReaders.selectUserIDs(users);
                    WebLog.Log("Email +" + users.id);
                    if (users.id != 0)
                    {
                        string encrypt = "";
                        try
                        {
                            encrypt = $"tK_{ Classes.Utility.RandomString(56).ToUpper()}" + users.id;
                            users   = DataReaders.getUser(Email);
                            WebLog.Log("users +" + users.Email);
                            string resetLink = ConfigurationManager.AppSettings["ResetPasswordLink"] + encrypt;
                            WebLog.Log("resetLink +" + resetLink);
                            string resetLink1 = "Click The Following Link:<a href='" + resetLink + "'>'" + resetLink + "'</a> to change your password";
                            WebLog.Log("resetLink1 +" + resetLink1);
                            WebLog.Log("resetLink: " + resetLink);
                            var bodyTxt = System.IO.File.ReadAllText(Server.MapPath("~/EmailNotifications/ResetPasswordEmailNotification.html"));
                            bodyTxt = bodyTxt.Replace("$MerchantName", $"{users.firstname} {users.lastname}");
                            bodyTxt = bodyTxt.Replace("$Message", $"{resetLink1}");
                            var msgHeader = $"Reset Your Password";
                            WebLog.Log("resetLink: " + resetLink);

                            WebLog.Log("bodyTxt:" + bodyTxt);

                            var sendMail = NotificationService.SendMail(msgHeader, bodyTxt, users.Email, null, null);
                            users.ResetPassword = encrypt;
                            users.DateTim       = Classes.Utility.GetCurrentDateTime();
                            DataCreators.UpdateUsers(users);
                            TempData["message"] = "Check Your Email For Password Reset Link";
                        }
                        catch (Exception ex)
                        {
                            ex.Message.ToString();
                            WebLog.Log(ex.Message.ToString());
                        }
                    }
                    else
                    {
                        TempData["message"] = "Please Try Again";
                    }
                }
                else
                {
                    TempData["message"] = "Account Does Not Exist";
                }
            }
            catch (Exception ex)
            {
                //Response.Write(ex.Message.ToString());
                WebLog.Log(ex.Message.ToString());
            }
        }