public int ValidateWebEmailAndSendCode(string emailId) { var expiredOn = Convert.ToInt32(ConfigurationManager.AppSettings["ExpiredValue"]); var isEmailExist = _accessTokenRepository.ValidWebEmail(emailId); if (!isEmailExist) { throw new Exception("Emailadressen finns inte."); } var webUser = _accessTokenRepository.GetWebUserByEmail(emailId); var webUserRecoverCode = new WebUserRecoveryCode { WebUserId = webUser.Id, RecoveryCode = _cryptoGraphy.GenerateCode(), ExpiredOn = DateTime.Now.AddMinutes(expiredOn) }; _accessTokenRepository.CreateNewWebUserRecoverCode(webUserRecoverCode); var fields = new StringDictionary { { "name", webUser.Name }, { "RecoveryCode", webUserRecoverCode.RecoveryCode }, { "ExpiredOn", expiredOn.ToString() } }; var htmlBody = _fm.ReadFileContents(GetMailerTemplatePath("html", "RecoveryCode")).ReplaceMatch(fields); _emailNotifier.SendEmail(webUser.Email, htmlBody, "Återställningskod"); var minutes = (expiredOn * 60) / 60; return(minutes); }
public void SendInvitation(InvitationModel model, long userId) { var checkEmail = _accessTokenRepository.GetWebUserByEmail(model.Email); if (checkEmail != null) { throw new Exception("L'identificador de correu electrònic ja existeix."); } var invitationId = InsertWebUserInvitation(model, userId); var webUrl = ConfigurationManager.AppSettings["WebUrl"]; var fields = new StringDictionary { { "signUpUrl", string.Format("{0}{1}{2}", webUrl, "/Employee/Invitation/", invitationId) } }; var htmlBody = _fm.ReadFileContents(GetMailerTemplatePath("html", "CreateEmployeePage")).ReplaceMatch(fields); _emailNotifier.SendEmail(model.Email, htmlBody, "Invitation"); }